2023-04-07 16:35:57 +04:00
|
|
|
|
using CaseAccountingContracts.BindingModels;
|
|
|
|
|
using CaseAccountingContracts.ViewModels;
|
|
|
|
|
using CaseAccountingDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace CaseAccountingDataBaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Deal : IDealModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public string Subject { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public string Responsibilities { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public DateTime Date { get; set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public int UserId { get; set; }
|
|
|
|
|
|
2023-04-07 23:33:56 +04:00
|
|
|
|
public virtual User User { get; set; } = new();
|
|
|
|
|
|
2023-04-07 16:35:57 +04:00
|
|
|
|
[ForeignKey("DealId")]
|
|
|
|
|
public virtual List<CaseDeal> CaseDeals { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
[ForeignKey("DealId")]
|
|
|
|
|
public virtual List<DealContract> Contracts { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
public static Deal? Create(DealBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Deal()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Subject = model.Subject,
|
|
|
|
|
Responsibilities = model.Responsibilities,
|
|
|
|
|
Date = model.Date,
|
|
|
|
|
UserId = model.UserId,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(DealBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Subject = model.Subject;
|
|
|
|
|
Responsibilities = model.Responsibilities;
|
|
|
|
|
Date = model.Date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DealViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Subject = Subject,
|
|
|
|
|
Responsibilities = Responsibilities,
|
|
|
|
|
Date = Date,
|
|
|
|
|
UserId = UserId
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|