Gismatullin.ISEbd-21.STO.Co.../ServiceStation/ServiceStationsDataBaseImplement/Models/Report.cs

55 lines
1.3 KiB
C#

using ServiceStationContracts.BindingModels;
using ServiceStationContracts.ViewModels;
using ServiceStationDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceStationsDataBaseImplement.Models
{
public class Report : ITaskModel
{
[Required]
public int Count { get; set; }
public int Id { get; set; }
public static Report? Create(ReportBindingModel? model)
{
if (model == null)
{
return null;
}
return new Report()
{
Id = model.Id,
Count = model.Count
};
}
public static Report? Create(TaskViewModel model)
{
return new Report
{
Id = model.Id,
Count = model.Count,
};
}
public void Update(ReportBindingModel model)
{
if (model == null)
{
return;
}
Count = model.Count;
}
public TaskViewModel GetViewModel => new()
{
Id = Id,
Count = Count
};
}
}