2023-04-06 22:52:23 +04:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-04-07 23:28:12 +04:00
|
|
|
|
using SchoolContracts.BindingModel;
|
|
|
|
|
using SchoolContracts.BindingModels;
|
|
|
|
|
using SchoolContracts.ViewModels;
|
2023-04-06 22:52:23 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SchoolDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class CircleExpense
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int ExpenseId { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int CircleId { get; set; }
|
|
|
|
|
public virtual Expense Expense { get; set; } = new();
|
|
|
|
|
public virtual Circle Circle { get; set; } = new();
|
2023-04-07 23:28:12 +04:00
|
|
|
|
public static CircleExpense? Create(SchoolDatabase context, CircleExpenseBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Circle = context.Circles.First(x => x.Id == model.CircleId),
|
|
|
|
|
Expense = context.Expenses.First(x => x.Id == model.ExpenseId)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(CircleExpenseBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CircleExpenseViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id
|
|
|
|
|
};
|
2023-04-06 22:52:23 +04:00
|
|
|
|
}
|
|
|
|
|
}
|