using ServiceStationContracts.BindingModels; using ServiceStationContracts.ViewModels; using ServiceStationDataModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ServiceStationsDataBaseImplement.Models { public class Work : IWorkModel { public DateTime Date { get; set; } = DateTime.Now; public int Price { get; set; } public WorkStatus Status { get; set; } = WorkStatus.Неизвестно; public int ExecutorId { get; set; } public int ReportId { get; set; } public int CategoryWorkId { get; set; } public int Id { get; set; } public static Work? Create(WorkBindingModel? model) { if (model == null) { return null; } return new Work() { Date = model.Date, Price = model.Price, Status = model.Status, ExecutorId = model.ExecutorId, ReportId = model.ReportId, CategoryWorkId = model.CategoryWorkId, Id = model.Id }; } public static Work? Create(WorkViewModel model) { return new Work { Date = model.Date, Price = model.Price, Status = model.Status, ExecutorId = model.ExecutorId, ReportId = model.ReportId, CategoryWorkId = model.CategoryWorkId, Id = model.Id }; } public void Update(WorkBindingModel model) { if (model == null) { return; } Date = model.Date; Price = model.Price; Status = model.Status; ExecutorId = model.ExecutorId; ReportId = model.ReportId; CategoryWorkId = model.CategoryWorkId; } public WorkViewModel GetViewModel => new() { Date = Date, Price = Price, Status = Status, ExecutorId = ExecutorId, ReportId = ReportId, CategoryWorkId = CategoryWorkId, Id = Id }; } }