public ActionResult Index() { PETiano petiano = LoggedPETiano.GetLogedPETiano(); PaymentFilter paymentFilter = new PaymentFilter() { PETianoId = petiano.Id }; List<Payment> payments = _PaymentService.GetPayments(paymentFilter); List<Payment> paymentsStatement = _PaymentService.GetAccountStatement(paymentFilter); PaymentIndex pi = new PaymentIndex(); pi.Balance = petiano.Balance; pi.Payments = payments; pi.PaymentsStatement = paymentsStatement; Payment credit = new Payment(); credit.Type = EPaymentType.Credit; credit.Date = DateTime.Now; credit.PETiano = petiano; credit.PETianoId = petiano.Id; pi.NewCredit = credit; return View(pi); }
public ActionResult AddCredit(PaymentIndex index) { if (index.NewCredit.Value <= 0 || string.IsNullOrEmpty(index.NewCredit.PenaltyJustification)) return View(); if (index.NewCredit.PhotoFile != null) { using (MemoryStream target = new MemoryStream()) { index.NewCredit.PhotoFile.InputStream.CopyTo(target); index.NewCredit.Photo = target.ToArray(); } } index.NewCredit.Date = DateTime.Now; index.NewCredit.Status = EPaymentStatus.WaitingApproval; index.NewCredit.Type = EPaymentType.Credit; _PaymentService.AddCredit(index.NewCredit); return RedirectToAction("Index"); }