51 lines
1.0 KiB
C#
Raw Normal View History

2024-08-10 18:43:15 +04:00
using ServiceStationContracts.BindingModels;
using ServiceStationContracts.ViewModels;
using ServiceStationDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
2024-08-23 19:44:26 +04:00
using System.ComponentModel.DataAnnotations.Schema;
2024-08-10 18:43:15 +04:00
using System.Linq;
using System.Text;
namespace ServiceStationsDataBaseImplement.Models {
public class TaskByWork : ITaskModel {
public int Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
2024-08-22 20:40:32 +04:00
[Required]
public double Price { get; set; }
2024-08-23 19:44:26 +04:00
[ForeignKey("TaskByWorkId")]
public virtual Work? work { get; set; }
2024-08-10 18:43:15 +04:00
public static TaskByWork? Create(TaskBindingModel? model) {
if (model == null) {
return null;
}
return new TaskByWork() {
Id = model.Id,
2024-08-22 20:40:32 +04:00
Name = model.Name,
Price = model.Price,
2024-08-10 18:43:15 +04:00
};
}
public void Update(TaskBindingModel? model) {
if (model == null) {
return;
}
Name = model.Name;
}
public TaskViewModel GetViewModel => new() {
Id = Id,
2024-08-22 20:40:32 +04:00
Name = Name,
Price = Price,
2024-08-10 18:43:15 +04:00
};
2024-08-22 20:40:32 +04:00
2024-08-10 18:43:15 +04:00
}
}