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

85 lines
2.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
};
}
}