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