public HttpResponseMessage GetListMyDebtsByFriendName(String nameOut) { DebtRepository debtRepository = new DebtRepository(); IList <Debt> listDebt = debtRepository.GetListMyDebtsByFriendName(nameOut); if (listDebt != null) { List <DebtViewModel> listDebtView = new List <DebtViewModel>(); FriendRepository friendName = new FriendRepository(); foreach (dynamic item in listDebt) { listDebtView.Add(new DebtViewModel { Id = item.Id, Date = Convert.ToString(item.Date), Description = item.Description, Value = item.Value.ToString(), FriendNameIn = friendName.GetFriendNameById(item.FriendIdIn).Trim(), FriendNameOut = friendName.GetFriendNameById(item.FriendIdOut).Trim() }); } return(Request.CreateResponse(HttpStatusCode.OK, listDebtView.ToArray())); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not find debt.")); }
public DebtViewModel(Debt debt) { debtRep = new DebtRepository(); ThePerson = debt.Person; TheDescription = debt.Description; TheCurrentValue = Convert.ToString(debt.CurrentValue); TheBorrowDate = debt.BorrowDate; TheDateOfDelivery = debt.DateOfDelivery; TheAmILender = debt.AmILender; UpdateDebtCommand = new Command(async() => { debt.CurrentValue += Convert.ToDouble(TheAddValue); debt.Progress = debt.CurrentValue / debt.DebtValue; if (debt.Progress > 1) { debt.DateOfDelivery = DateTime.Now; } await debtRep.SaveDebtAsync(debt); ThePerson = string.Empty; TheDescription = string.Empty; TheCurrentValue = string.Empty; TheDebtValue = string.Empty; TheAmILender = false; TheDateOfDelivery = DateTime.MinValue; TheBorrowDate = DateTime.MinValue; }); RemoveDebt = new Command(async() => { await debtRep.DeleteDebtAsync(debt); }); }
public DebtViewModel() { DebtRepository debtRepository = new DebtRepository(); List <Debt> list = debtRepository.GetDebts(); this.Debts = new ObservableCollection <Debt>(list); }
public HttpResponseMessage CreatePayment([FromUri] int debtId) { MessageViewModel messageAttribute = new MessageViewModel(); Debt debt = new Debt(); if (paymentRepository == null) { DebtRepository debtRepository = new DebtRepository(); debt = debtRepository.GetDebtById(debtId); if (debt != null) { PaymentRepository paymentRepository = new PaymentRepository(); Boolean sucess = paymentRepository.Insert(debt); if (sucess) { return(Request.CreateResponse(HttpStatusCode.Created, messageAttribute.Create())); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not create payment.")); } } else { paymentRepository.Insert(debt); } return(Request.CreateResponse(HttpStatusCode.Created, messageAttribute.Create())); }
static void Main(string[] args) { var d = new DebtRepository(); Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(d.AllBanks())); Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(d.AllPersons())); Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(d.DebtsForPeopleAndBanks())); }
public HttpResponseMessage UpdateDebt([FromBody] DebtViewModel debtAttribute, [FromUri] int debtId) { Validates validates = new Validates(); MessageViewModel messageAttribute = new MessageViewModel(); String Message = validates.ValidateUpdateDebt(debtAttribute, debtId); if (Message == String.Empty) { Debt debt = new Debt(); FriendRepository friendName = new FriendRepository(); Boolean sucess; if (debtRepository == null) { DebtRepository debtRepository = new DebtRepository(); debt = debtRepository.GetDebtById(debtId); if (debt != null) { debtAttribute.Id = debtId; debt.Value = Convert.ToDecimal(debtAttribute.Value); debt.Date = Convert.ToDateTime(debtAttribute.Date); debt.Description = debtAttribute.Description; debt.FriendIdIn = friendName.GetFriendIdByName(debtAttribute.FriendNameIn); debt.FriendIdOut = friendName.GetFriendIdByName(debtAttribute.FriendNameOut); sucess = debtRepository.Update(debt, debtId); if (sucess) { return(Request.CreateResponse(HttpStatusCode.OK, debtAttribute)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not update debt.")); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not find debt.")); } } else { debt = debtRepository.GetDebtById(debtId); sucess = debtRepository.Update(debt, debtId); if (sucess) { return(Request.CreateResponse(HttpStatusCode.OK, debt)); } } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not find debt.")); } else { return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, Message)); } }
public HttpResponseMessage GetTotalDebts(String name) { DebtRepository debtRepository = new DebtRepository(); String totalDebt = debtRepository.GetTotalDebtsByFriendName(name); if (totalDebt != "") { return(Request.CreateResponse(HttpStatusCode.OK, totalDebt)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not find debt.")); }
public DebtViewModel() { debtRep = new DebtRepository(); SaveDebtCommand = new Command(async() => { var debt = new Debt(); debt.Person = ThePerson; debt.Description = TheDescription; debt.DebtValue = Convert.ToDouble(TheDebtValue); debt.CurrentValue = 0; debt.BorrowDate = TheBorrowDate; debt.DateOfDelivery = TheDateOfDelivery; debt.AmILender = TheAmILender; debt.Progress = debt.CurrentValue / debt.DebtValue; await debtRep.SaveDebtAsync(debt); }); }
public HttpResponseMessage DeleteDebtById([FromUri] int debtId) { Validates validates = new Validates(); MessageViewModel messageAttribute = new MessageViewModel(); String Message = validates.ValidateDelete(debtId); if (Message == String.Empty) { Debt debt = new Debt(); Boolean sucess; if (debtRepository == null) { DebtRepository debtRepository = new DebtRepository(); debt = debtRepository.GetDebtById(debtId); if (debt != null) { sucess = debtRepository.DeleteObject(debt, true); if (sucess) { return(new HttpResponseMessage(HttpStatusCode.NoContent)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not delete record.")); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Register not found.")); } else { debt = debtRepository.GetDebtById(debtId); sucess = debtRepository.DeleteObject(debt, true); if (sucess) { return(new HttpResponseMessage(HttpStatusCode.NoContent)); } } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Register not found.")); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Message)); }
public HttpResponseMessage CreateDebt([FromBody] DebtViewModel debtAttribute) { Validates validates = new Validates(); MessageViewModel messageAttribute = new MessageViewModel(); var Message = validates.ValidateDebt(debtAttribute); if (Message == String.Empty) { Debt debt = new Debt(); Boolean sucess; if (debtRepository == null) { DebtRepository debtRepository = new DebtRepository(); debt.Value = Convert.ToDecimal(debtAttribute.Value); debt.Date = Convert.ToDateTime(debtAttribute.Date); debt.Description = debtAttribute.Description; FriendRepository friendName = new FriendRepository(); debt.FriendIdIn = friendName.GetFriendIdByName(debtAttribute.FriendNameIn); debt.FriendIdOut = friendName.GetFriendIdByName(debtAttribute.FriendNameOut); sucess = debtRepository.Insert(debt); if (sucess) { return(Request.CreateResponse(HttpStatusCode.Created, messageAttribute.Create())); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not create debit.")); } else { sucess = debtRepository.Insert(debt); if (sucess) { return(Request.CreateResponse(HttpStatusCode.Created, messageAttribute.Create())); } } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not create debit.")); } return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, Message)); }
public DebtVM(User _user) { User = _user; Title = "Кредиты"; repository = new DebtRepository(_user); Debts = new ObservableCollection <Debt>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <NewDebtPage, Debt>(this, "AddDebt", (obj, item) => { Debts.Insert(0, item as Debt); }); //MessagingCenter.Subscribe<NewOperationPage, Operation>(this, "UpdateOperation", (obj, item) => { // var newItem = item as Operation; // var oldItem = Operations[Operations.IndexOf(Operations.FirstOrDefault(i => i.Id == newItem.Id))]; // //await opRepository.UpdateItemAsync(newItem); //}); }
public DebtDetailVM(Debt newDebt, User _user, DebtRepository _repository = null) { Title = newDebt?.Title.ToString(); repository = _repository; User = _user; ListForPickerType = new List <string> { "Ежемесячный возврат части кредита", "Аннуитетный платеж", "Единовременный возврат кредита" }; if (newDebt == null) { Debt = new Debt(_user); } else { Debt = newDebt; adding = false; } }
public HttpResponseMessage GetDebtById(int debtId) { Debt getDebt = new Debt(); if (debtRepository == null) { DebtRepository debtRepository = new DebtRepository(); getDebt = debtRepository.GetDebtById(debtId); if (getDebt != null) { DebtViewModel debt = new DebtViewModel(); FriendRepository friendName = new FriendRepository(); debt.Id = getDebt.Id; debt.Value = getDebt.Value.ToString(); debt.Date = Convert.ToString(getDebt.Date); debt.Description = getDebt.Description; debt.FriendNameIn = friendName.GetFriendNameById(getDebt.FriendIdIn).Trim(); debt.FriendNameOut = friendName.GetFriendNameById(getDebt.FriendIdOut).Trim(); return(Request.CreateResponse(HttpStatusCode.OK, debt)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not find debt.")); } else { getDebt = debtRepository.GetDebtById(debtId); if (getDebt != null) { return(Request.CreateResponse(HttpStatusCode.OK, getDebt)); } } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not find debt.")); }
public NewDebtPage(Debt newDebt, User _user, DebtRepository _repository) { InitializeComponent(); BindingContext = debtVM = new DebtDetailVM(newDebt, _user, _repository); InitSelectedPickers(newDebt); }
public DebtListViewModel() { DebtRep = new DebtRepository(); }
public AddDebt() { InitializeComponent(); this.debtRepository = new DebtRepository(); this.debtRepository.CreateBD(); }
public DebtModel() { this._Repository = new DebtRepository(); this.Debt = new Debt(); }
public DebtListPage() { InitializeComponent(); this.debtRepository = new DebtRepository(); this.debtRepository.CreateBD(); }
public LoansOperationsRepository(DebtRepository repo) { _repo = repo; }
public BankOperationsRepository(DebtRepository repo) { _repo = repo; }