54 lines
1.2 KiB
C#
54 lines
1.2 KiB
C#
using SchoolContracts.BindingModel;
|
|
using SchoolContracts.BindingModels;
|
|
using SchoolContracts.ViewModels;
|
|
using SchoolDataModels.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 SchoolDatabaseImplement.Models
|
|
{
|
|
public class Expense : IExpenseModel
|
|
{
|
|
public int Id { get; private set; }
|
|
public string ExpenseName { get; private set; } = string.Empty;
|
|
[Required]
|
|
public double Sum { get; private set; }
|
|
[ForeignKey("ExpenseId")]
|
|
public virtual List<CircleExpense> CircleExpenses { get; set; } = new();
|
|
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
|
|
};
|
|
}
|
|
}
|