public ActionResult Retrieve([Bind(Include = "CollectionDate")] RetrievalItemsWithDateDTO listWithDate) { if (ModelState.IsValid) { var selectedDate = DateTime.ParseExact(listWithDate.CollectionDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); var disbursements = CreateDisbursement(selectedDate); foreach (var disbursement in disbursements) { var repEmail = _employeeRepo.GetRepByDeptCode(disbursement.DeptCode).EmailAddress; var collectionPoint = _collectionRepo.GetById((int)disbursement.CollectionPointId); var email = new LUSSISEmail.Builder().From(User.Identity.Name).To(repEmail) .ForNewDisbursement(disbursement, collectionPoint).Build(); new Thread(delegate() { EmailHelper.SendEmail(email); }).Start(); } return(RedirectToAction("RetrievalInProcess")); } return(View("Consolidated", new RetrievalItemsWithDateDTO { RetrievalItems = CreateRetrievalList().List.ToPagedList(1, 15), CollectionDate = DateTime.Today.ToString("dd/MM/yyyy"), HasInprocessDisbursement = _disbursementRepo.HasInprocessDisbursements() })); }
public IActionResult Get(int id) { var collection = _collectionRepository.GetById(id); if (collection != null) { NotFound(); } return(Ok(collection)); }
public void CollectionRepository_CollectionNotFound() { using (var context = DataCreation.CreateDb("CollectionRepository_CollectionNotFound")) { //ARRANGE var repo = new CollectionRepository(new DatabaseFactory(context)); var collections = DataCreation.CreateCollections(); context.AddRange(collections); context.SaveChanges(); //ACT var collection = repo.GetById(Guid.NewGuid()); //ASSERT Assert.IsNull(collection); } }
public void CollectionRepository_Basic() { using (var context = DataCreation.CreateDb("CollectionRepository_Basic")) { //ARRANGE var repo = new CollectionRepository(new DatabaseFactory(context)); repo.Mapper = CreateMapper(); var collections = DataCreation.CreateCollections(); context.AddRange(collections); context.SaveChanges(); //ACT var collection = repo.GetById(collections[1].Id); //ASSERT Assert.AreEqual("Collection 2", collection.Name); Assert.AreEqual(collections[1].Id, collection.Id); } }
public ActionResult Edit([Bind(Include = "DisbursementId, CollectionDate, CollectionPointId, AcknowledgeEmpNum, DeptCode, Status")] Disbursement disbursement) { if (ModelState.IsValid) { _disbursementRepo.Update(disbursement); var repEmail = _employeeRepo.GetRepByDeptCode(disbursement.DeptCode).EmailAddress; if (disbursement.CollectionPointId != null) { var collectionPoint = _collectionRepo.GetById((int)disbursement.CollectionPointId); var email = new LUSSISEmail.Builder().From(User.Identity.Name).To(repEmail) .ForUpdateDisbursement(disbursement, collectionPoint).Build(); new System.Threading.Thread(delegate() { EmailHelper.SendEmail(email); }).Start(); } return(RedirectToAction("Upcoming")); } ViewBag.CollectionPointId = new SelectList(_collectionRepo.GetAll(), "CollectionPointId", "CollectionName", disbursement.CollectionPointId); return(View(disbursement)); }