2023-04-07 23:28:12 +04:00
|
|
|
|
using SchoolContracts.BindingModel;
|
|
|
|
|
using SchoolContracts.BindingModels;
|
|
|
|
|
using SchoolContracts.ViewModels;
|
|
|
|
|
using SchoolDataModels.Models;
|
2023-04-06 22:52:23 +04:00
|
|
|
|
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 SchoolDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Expense : IExpenseModel
|
|
|
|
|
{
|
2023-04-07 00:30:18 +04:00
|
|
|
|
public int Id { get; private set; }
|
2023-04-07 23:28:12 +04:00
|
|
|
|
public string ExpenseName { get; private set; } = string.Empty;
|
2023-04-06 22:52:23 +04:00
|
|
|
|
[Required]
|
2023-04-07 00:30:18 +04:00
|
|
|
|
public double Sum { get; private set; }
|
2023-04-06 22:52:23 +04:00
|
|
|
|
[ForeignKey("ExpenseId")]
|
|
|
|
|
public virtual List<CircleExpense> CircleExpenses { get; set; } = new();
|
2023-04-07 23:28:12 +04:00
|
|
|
|
public static Expense? Create(ExpenseBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
ExpenseName = model.ExpenseName,
|
|
|
|
|
Sum = model.Sum
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(ExpenseBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ExpenseName = model.ExpenseName;
|
|
|
|
|
Sum = model.Sum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ExpenseViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
ExpenseName = ExpenseName,
|
|
|
|
|
Sum = Sum
|
|
|
|
|
};
|
2023-04-06 22:52:23 +04:00
|
|
|
|
}
|
|
|
|
|
}
|