61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using Microsoft.IdentityModel.Abstractions;
|
|
using ServiceStationContracts.BindingModels;
|
|
using ServiceStationContracts.ViewModels;
|
|
using ServiceStationDataModels;
|
|
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 CategoryWork : ICategoryWorkModel
|
|
{
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
[Required]
|
|
public int ExecutorId { get; set; }
|
|
|
|
public int ID { get; set; }
|
|
public static CategoryWork? Create(CategoryWorkBindingModel? model)
|
|
{
|
|
if(model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new CategoryWork()
|
|
{
|
|
Name = model.Name,
|
|
ExecutorId = model.ExecutorId,
|
|
ID = model.ID
|
|
};
|
|
}
|
|
public static CategoryWork? Create(CategoryWorkViewModel model)
|
|
{
|
|
return new CategoryWork
|
|
{
|
|
Name = model.Name,
|
|
ExecutorId = model.ExecutorId,
|
|
ID = model.ID
|
|
};
|
|
}
|
|
public void Update(CategoryWorkBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Name = model.Name;
|
|
ExecutorId = model.ExecutorId;
|
|
}
|
|
public CategoryWorkViewModel GetViewModel => new()
|
|
{
|
|
ID = ID,
|
|
Name = Name,
|
|
ExecutorId = ExecutorId
|
|
};
|
|
}
|
|
}
|