public void PaymentVoucher_ShouldComeWithEntriesWhenInitialized() { var voucher = new PaymentVoucher(); Assert.IsNotNull(voucher.Entries); Assert.AreEqual(PaymentVoucher.NumberOfEntriesInAVoucher, voucher.Entries.Count); }
public void InitVoucher() { var project = new Project(); project.Name = "Test"; Voucher = new PaymentVoucher(); Voucher.Project = project; Voucher.CheckNumber = "123"; Voucher.PaidTo = "Kevin"; var entry = new PaymentVoucherEntry(); entry.Item = "someting"; entry.CostElement = "big"; entry.Amount = 234.23; Voucher.Entries.Add(entry); entry = new PaymentVoucherEntry(); entry.Item = "someting else"; entry.CostElement = "not so big"; entry.Amount = .01; Voucher.Entries.Add(entry); entry = new PaymentVoucherEntry(); entry.Item = "that thing"; entry.CostElement = "small"; entry.Amount = 2304990324.3; Voucher.Entries.Add(entry); }
public ActionResult Create(Guid ProjectID) { var v = new PaymentVoucher(); v.Project = ProjectRepository.FindProjectByID(ProjectID); v.PreparedBy = UserRepository.CurrentUserName; return View("Edit",v); }
public void Create(PaymentVoucher Voucher) { if (Voucher == null) return; foreach (var entry in Voucher.Entries) { entry.PaymentVoucherID = Voucher.ID; }; //Voucher.RemoveBlankEntries(); db.PaymentVouchers.Add(Voucher); db.SaveChanges(); }
public ActionResult Create(Guid ProjectID, PaymentVoucher model) { //model.PreparedBy = repo if (ModelState.IsValid) { PaymentVoucherRepository.Create(model); return RedirectToAction("Index"); } else { model.Project = ProjectRepository.FindProjectByID(ProjectID); return View("Edit", model); } }
public ActionResult Edit(PaymentVoucher model) { var vouchers = new PaymentVoucherRepository(); model.PreparedBy = UserRepository.CurrentUserName; if (ModelState.IsValid) { vouchers.Update(model); return RedirectToAction("Index", new { ProjectID = model.ProjectID }); } else { var v = vouchers.Get(model.ID); model.Project = v.Project; return View("Edit", model); } }
public void PaymentVoucherController_Index_ShouldReturnAllVouchersForAProject() { var project = new Project(); projectRepository.Create(project); int voucherCount = 13; for (int i = 0; i < voucherCount; i++) { var voucher = new PaymentVoucher(); voucher.ProjectID = project.ID; paymentVoucherRepository.Create(voucher); } var result = controller.Index(project.ID) as ViewResult; var model = result.Model as PaymentVouchersViewModel; Assert.AreEqual(voucherCount, model.Vouchers.Count()); }
public void Delete(PaymentVoucher voucher) { db.PaymentVouchers.Remove(voucher); db.SaveChanges(); }
public void Update(PaymentVoucher Voucher) { if (Voucher == null) return; //Delete the previosu entries var org = db.PaymentVouchersEntries.Where(col => col.PaymentVoucherID == Voucher.ID).ToList(); foreach (var entry in org) { db.PaymentVouchersEntries.Remove(entry); } db.SaveChanges(); //Load the original Voucher into our db context var voucher = Get(Voucher.ID); //update the voucher db.Entry(voucher).CurrentValues.SetValues(Voucher); //and each entry for (int i = 0; i < Voucher.Entries.Count; i++) { db.Entry(voucher.Entries[i]).CurrentValues.SetValues(Voucher.Entries[i]); } //commit changes db.SaveChanges(); }
private PaymentVoucher createTestVoucher() { var voucher = new PaymentVoucher(); voucher.ApprovedBy = "321"; voucher.CheckNumber = "123"; voucher.Date = DateTime.Now; voucher.PaidTo = "321"; voucher.ProjectID = project.ID; voucher.RBCApproval = "321"; voucher.TaxCostElement = "blah"; return voucher; }