2024-04-30 19:55:37 +03:00
|
|
|
|
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; }
|
|
|
|
|
|
2024-08-03 19:12:18 +04:00
|
|
|
|
public int ID { get; set; }
|
2024-04-30 19:55:37 +03:00
|
|
|
|
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,
|
2024-08-03 19:12:18 +04:00
|
|
|
|
ID = model.ID
|
2024-04-30 19:55:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
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,
|
2024-08-03 19:12:18 +04:00
|
|
|
|
ID = model.ID
|
2024-04-30 19:55:37 +03:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
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,
|
2024-08-03 19:12:18 +04:00
|
|
|
|
ID = ID
|
2024-04-30 19:55:37 +03:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|