diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CreditingLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CreditingLogic.cs index 7b2074b..e82a413 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CreditingLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CreditingLogic.cs @@ -100,13 +100,13 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics { throw new ArgumentNullException("Сумма операции должна быть больше 0", nameof(model.Sum)); } - if (model.date < DateTime.Now) + if (model.Date < DateTime.Now) { - throw new ArgumentNullException("Дата не может быть меньше текущего времени", nameof(model.date)); + throw new ArgumentNullException("Дата не может быть меньше текущего времени", nameof(model.Date)); } _logger.LogInformation("Crediting. Sum:{Sum}.CardId:{CardId}.Date:{date}.Id:{Id}", - model.Sum, model.CardId, model.date.ToString(), model.Id); + model.Sum, model.CardId, model.Date.ToString(), model.Id); } } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/DebitingLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/DebitingLogic.cs index d78d857..866943b 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/DebitingLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/DebitingLogic.cs @@ -100,13 +100,13 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics { throw new ArgumentNullException("Сумма операции должна быть больше 0", nameof(model.Sum)); } - if (model.date < DateTime.Now) + if (model.Date < DateTime.Now) { - throw new ArgumentNullException("Дата не может быть меньше текущего времени", nameof(model.date)); + throw new ArgumentNullException("Дата не может быть меньше текущего времени", nameof(model.Date)); } _logger.LogInformation("Debiting. Sum:{Sum}.CardId:{CardId}.Date:{date}.Id:{Id}", - model.Sum, model.CardId, model.date.ToString(), model.Id); + model.Sum, model.CardId, model.Date.ToString(), model.Id); } } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CreditingBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CreditingBindingModel.cs index c8c6913..440830b 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CreditingBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CreditingBindingModel.cs @@ -15,6 +15,6 @@ namespace BankYouBankruptContracts.BindingModels public int Sum { get; set; } - public DateTime date { get; set; } = DateTime.Now; + public DateTime Date { get; set; } = DateTime.Now; } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs index f655c1f..8b2ec1c 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/DebitingBindingModel.cs @@ -15,6 +15,6 @@ namespace BankYouBankruptContracts.BindingModels public int Sum { get; set; } - public DateTime date { get; set; } = DateTime.Now; + public DateTime Date { get; set; } = DateTime.Now; } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CreditingViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CreditingViewModel.cs index 1ded21f..5a31584 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CreditingViewModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CreditingViewModel.cs @@ -21,6 +21,6 @@ namespace BankYouBankruptContracts.ViewModels public int Sum { get; set; } [DisplayName("Дата операции")] - public DateTime date { get; set; } = DateTime.Now; + public DateTime Date { get; set; } = DateTime.Now; } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs index 138517e..22f80e9 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs @@ -21,6 +21,6 @@ namespace BankYouBankruptContracts.ViewModels public int Sum { get; set; } [DisplayName("Дата операции")] - public DateTime date { get; set; } = DateTime.Now; + public DateTime Date { get; set; } = DateTime.Now; } } diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Models/ICreditingModel.cs b/BankYouBankrupt/BankYouBankruptDataModels/Models/ICreditingModel.cs index fb0f4f1..40d91c1 100644 --- a/BankYouBankrupt/BankYouBankruptDataModels/Models/ICreditingModel.cs +++ b/BankYouBankrupt/BankYouBankruptDataModels/Models/ICreditingModel.cs @@ -13,6 +13,6 @@ namespace BankYouBankruptDataModels.Models int Sum { get; } - DateTime date { get; } + DateTime Date { get; } } } diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Models/IDebitingModel.cs b/BankYouBankrupt/BankYouBankruptDataModels/Models/IDebitingModel.cs index d67a9e3..6ad9cfd 100644 --- a/BankYouBankrupt/BankYouBankruptDataModels/Models/IDebitingModel.cs +++ b/BankYouBankrupt/BankYouBankruptDataModels/Models/IDebitingModel.cs @@ -13,6 +13,6 @@ namespace BankYouBankruptDataModels.Models int Sum { get; } - DateTime date { get; } + DateTime Date { get; } } } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Card.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Card.cs index f520b99..2706ce7 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Card.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Card.cs @@ -1,6 +1,9 @@ -using BankYouBankruptDataModels.Models; +using BankYouBankruptContracts.BindingModels; +using BankYouBankruptContracts.ViewModels; +using BankYouBankruptDataModels.Models; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,16 +12,47 @@ namespace BankYouBankruptDatabaseImplement.Models { public class Card : ICardModel { - public int ClientID => throw new NotImplementedException(); + public int Id { get; set; } + [Required] + public int ClientID { get; set; } - public int AccountId => throw new NotImplementedException(); + public virtual Client Client { get; set; } = new(); + [Required] + public int AccountId { get; set; } + [Required] + public string Number { get; set; } = String.Empty; + [Required] + public string CVC { get; set; } + [Required] + public DateTime Period { get; set; } = DateTime.Now; - public string Number => throw new NotImplementedException(); + public CardViewModel GetViewModel => new() + { + Id = Id, + ClientID = ClientID, + ClientSurname = Client.Surname, + Number = Number, + Period = Period, + CVC = CVC + }; - public string CVC => throw new NotImplementedException(); + public static Card Create(BankYouBancruptDatabase context, CardBindingModel model) + { + return new Card() + { + Id = model.Id, + ClientID = model.ClientID, + Client = context.Clients.First(x => x.Id == model.ClientID), + Number = model.Number, + Period = model.Period, + CVC = model.CVC + }; + } - public DateTime Period => throw new NotImplementedException(); - - public int Id => throw new NotImplementedException(); + public void Update(CardBindingModel model) + { + Period = model.Period; + } } } + diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Client.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Client.cs index 98c71f3..3ccde4d 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Client.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Client.cs @@ -1,6 +1,10 @@ -using BankYouBankruptDataModels.Models; +using BankYouBankruptContracts.BindingModels; +using BankYouBankruptContracts.ViewModels; +using BankYouBankruptDataModels.Models; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,18 +13,61 @@ namespace BankYouBankruptDatabaseImplement.Models { public class Client : IClientModel { - public string Password => throw new NotImplementedException(); + public int Id { get; set; } - public string Name => throw new NotImplementedException(); + [Required] + public string Name { get; set; } = string.Empty; - public string Surname => throw new NotImplementedException(); + [Required] + public string Surname { get; set; } = string.Empty; - public string Patronymic => throw new NotImplementedException(); + [Required] + public string Patronymic { get; set; } = string.Empty; - public string Email => throw new NotImplementedException(); + [Required] + public string Telephone { get; set; } = string.Empty; - public string Telephone => throw new NotImplementedException(); + [Required] + public string Email { get; set; } = string.Empty; - public int Id => throw new NotImplementedException(); + [Required] + public string Password { get; set; } = string.Empty; + + + public ClientViewModel GetViewModel => new() + { + Id = Id, + Name = Name, + Surname = Surname, + Patronymic = Patronymic, + Telephone = Telephone, + Email = Email, + Password = Password + }; + + public static Client Create(ClientBindingModel model) + { + return new Client() + { + Id = model.Id, + Name = model.Name, + Surname = model.Surname, + Patronymic = model.Patronymic, + Telephone = model.Telephone, + Email = model.Email, + Password = model.Password + }; + } + + public void Update(ClientBindingModel model) + { + Name = model.Name; + Surname = model.Surname; + Patronymic = model.Patronymic; + Telephone = model.Telephone; + Email = model.Email; + Password = model.Password; + } } } + diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Crediting.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Crediting.cs index 1c86056..9facd61 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Crediting.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Crediting.cs @@ -1,6 +1,9 @@ -using BankYouBankruptDataModels.Models; +using BankYouBankruptContracts.BindingModels; +using BankYouBankruptContracts.ViewModels; +using BankYouBankruptDataModels.Models; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,12 +12,41 @@ namespace BankYouBankruptDatabaseImplement.Models { public class Crediting : ICreditingModel { - public int CardId => throw new NotImplementedException(); - public int Sum => throw new NotImplementedException(); + public int Id { get; set; } - public DateTime date => throw new NotImplementedException(); + [Required] + public int CardId { get; set; } - public int Id => throw new NotImplementedException(); + [Required] + public int Sum { get; set; } + + [Required] + public DateTime Date { get; set; } = DateTime.Now; + + + public CreditingViewModel GetViewModel => new() + { + Id = Id, + CardId = CardId, + Sum = Sum, + Date = Date + }; + + public static Crediting Create(CreditingBindingModel model) + { + return new Crediting() + { + Id = model.Id, + CardId = model.CardId, + Sum = model.Sum, + Date = model.Date + }; + } + + public void Update(CreditingBindingModel model) + { + + } } } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs index 27918f4..afdae1d 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs @@ -1,6 +1,9 @@ -using BankYouBankruptDataModels.Models; +using BankYouBankruptContracts.BindingModels; +using BankYouBankruptContracts.ViewModels; +using BankYouBankruptDataModels.Models; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,12 +12,40 @@ namespace BankYouBankruptDatabaseImplement.Models { public class Debiting : IDebitingModel { - public int CardId => throw new NotImplementedException(); + public int Id { get; set; } - public int Sum => throw new NotImplementedException(); + [Required] + public int CardId { get; set; } - public DateTime date => throw new NotImplementedException(); + [Required] + public int Sum { get; set; } - public int Id => throw new NotImplementedException(); + [Required] + public DateTime Date { get; set; } = DateTime.Now; + + + public DebitingViewModel GetViewModel => new() + { + Id = Id, + CardId = CardId, + Sum = Sum, + Date = Date + }; + + public static Debiting Create(DebitingBindingModel model) + { + return new Debiting() + { + Id = model.Id, + CardId = model.CardId, + Sum = model.Sum, + Date = model.Date + }; + } + + public void Update(DebitingBindingModel model) + { + + } } }