public ApiDisbursementListListView(DisbursementList disbursement, UnitOfWork uow) { ID = disbursement.ID.ToString(); DepartmentID = disbursement.Department.ID; Status = disbursement.Status.ToString(); Location = uow.DepartmentRepository.Get(filter: x => x.ID == disbursement.Department.ID, includeProperties: "CollectionPoint").FirstOrDefault().CollectionPoint.Location; }
public bool ProcessRejectedDisbursement(Staff staff, int DisbursementID) { UnitOfWork uow = new UnitOfWork(); DisbursementList dl = uow.DisbursementListRepository.Get(filter: x => x.ID == DisbursementID, includeProperties: "ItemTransactions.Item").FirstOrDefault(); if (dl == null) { return(false); } AdjustmentVoucher adjustmentVoucher = new AdjustmentVoucher(dl, uow, staff); if (adjustmentVoucher == null) { return(false); } if (uow.StockCardEntryRepository.ProcessAdjustmentVoucher(adjustmentVoucher)) { uow.AdjustmentVoucherRepository.Insert(adjustmentVoucher); uow.Save(); Debug.WriteLine("Adjustment Voucher inserted successfully into DB for rejected DL"); //Update the respective inventory item foreach (DocumentItem di in adjustmentVoucher.DocumentItems) { if (!UpdateInStoreQty(di.Item.ID)) { Debug.WriteLine("Update In Store Qty failed for" + di.Item.ID); } } return(true); } return(false); }
public async Task <IActionResult> Edit(string id, [Bind("Dlid,StartDate,EstDeliverDate,CompleteDate,DepartmentCode,RepId,CollectionPointId,Status")] DisbursementList disbursementList) { if (id != disbursementList.Dlid) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(disbursementList); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DisbursementListExists(disbursementList.Dlid)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CollectionPointId"] = new SelectList(_context.CollectionPoint, "CollectionPointId", "CollectionPointName", disbursementList.CollectionPointId); ViewData["DepartmentCode"] = new SelectList(_context.Department, "DepartmentCode", "DepartmentCode", disbursementList.DepartmentCode); //ViewData["RepId"] = new SelectList(_context.User, "UserId", "DepartmentCode", disbursementList.RepId); return(View(disbursementList)); }
public ApiDisbursementListLogView(DisbursementList disbursement) { ID = disbursement.ID.ToString(); DepartmentID = disbursement.Department.ID; Status = disbursement.Status.ToString(); Date = disbursement.ResponseDate.ToString(); }
public HttpResponseMessage UpdateStatus(DisbursementList id) { ds.UpdateStatus(id); List <DisbursementList> requisitionLists = ds.ShowDisbursementList(); return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { model = requisitionLists })); }
public ApiDisbursementListView(DisbursementList dl) { ID = dl.ID.ToString(); CreatedByStaffID = dl.CreatedByStaff.ID.ToString(); CreatedByStaffName = dl.CreatedByStaff.Name; if (dl.RepliedByStaff != null) { RepliedByStaffID = dl.RepliedByStaff.ID.ToString(); RepliedByStaffName = dl.RepliedByStaff.Name; } else { RepliedByStaffID = ""; RepliedByStaffName = ""; } DepartmentID = dl.Department.ID; CollectionPoint = dl.Department.CollectionPoint.Location; OTP = dl.OTP.ToString(); Comments = dl.Comments; CreatedDate = dl.CreatedDate.ToString(); ResponseDate = dl.ResponseDate.ToString(); Status = dl.Status.ToString(); transactionItemViewList = new List <ApiTransactionItemView>(); foreach (TransactionItem ti in dl.ItemTransactions) { transactionItemViewList.Add(new ApiTransactionItemView(ti)); } }
public async Task <IActionResult> Index(User u) { if (ModelState.IsValid) { int newUserId = u.UserId; Department d2 = new Department(); d2 = context.Department.Where(x => x.DepartmentCode == dept).First(); d2.RepId = newUserId; var t = context.DisbursementList.Where(x => x.DepartmentCode == dept && x.Status == "Pending Delivery"); if (t.Any()) { DisbursementList d3 = new DisbursementList(); d3 = t.First(); d3.RepId = newUserId; } context.SaveChanges(); TempData["Alert1"] = "Department representative changed successfully!"; //send email to new dept rep var q = context.User.Where(x => x.UserId == u.UserId).First(); string email = q.EmailAddress; await _emailSender.SendEmailAsync(email, "Department Representative Appointment", "Dear " + q.Name + ",<br>You have been appointed as the department representative for stationery collection."); //send email to old dept rep var q2 = context.User.Where(x => x.UserId == oldrepid).First(); string email2 = q2.EmailAddress; await _emailSender.SendEmailAsync(email2, "Department Representative Replacement", "Dear " + q2.Name + ",<br>You have been replaced as department representative."); return(RedirectToAction("Index")); } TempData["Alert2"] = "Please try again"; return(RedirectToAction("Index")); }
private int?CreateNewDisbursementListForDepartment(DisbursementList dList, Requisition requisition, RetrievalList retrievalList, int?currentDisbursementListId, DateTime?deliverydate) { Department d = db.Departments.Find(requisition.DepartmentId); dList.DepartmentId = d.DepartmentId; dList.RetrievalId = retrievalList.retrievalId; dList.Status = "Processing"; if (deliverydate != null) { dList.DeliveryDate = deliverydate; } else { dList.DeliveryDate = DateTime.Today.AddDays(utilSvc.DaysToAdd(DateTime.Today.DayOfWeek, DayOfWeek.Friday)); } db.Set(typeof(DisbursementList)).Attach(dList); db.DisbursementLists.Add(dList); db.SaveChanges(); // creates new disbursementlist currentDisbursementListId = db.DisbursementLists .OrderByDescending(x => x.DisbursementListId) .FirstOrDefault().DisbursementListId; //returns created disbursementlist Id try //email to notify manager of approval { string emailBody = dList.Department.Representative.EmployeeName + ", you have a disbursement scheduled for collection on " + dList.DeliveryDate + " " + dList.Department.CollectionPoint.CollectTime + " at " + dList.Department.CollectionPoint.PlaceName + ". Please click on http://" + utilSvc.GetBaseUrl() + "/Representative/ViewDisbursementDetail/" + dList.DisbursementListId + " to view details for confirmation."; utilSvc.SendEmail(new List <string>(new string[] { dList.Department.Representative.Email }), "New Disbursement Scheduled for Collection", emailBody); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } return(currentDisbursementListId); }
public ApiDisbursementListView GetByID(int id) { DisbursementList dl = uow.DisbursementListRepository.Get(filter: x => x.ID == id, includeProperties: "Department, CreatedByStaff, RepliedByStaff, Department.CollectionPoint").FirstOrDefault(); ApiDisbursementListView apiDisbursementListView = new ApiDisbursementListView(dl); return(apiDisbursementListView); }
private void BindLabels(int disbursementId) { DisbursementList dL = DisbursementLogic.GetDisbursementList(disbursementId); string status = dL.Status; LblDisbId.Text = "DL" + disbursementId.ToString("0000"); LblColDate.Text = ((DateTime)dL.CollectionDate).ToString("d"); LblCollectPoint.Text = DisbursementLogic.GetCurrentCPWithTimeByID(dL.CollectionPointID); LblDeptRep.Text = dL.RepresentativeName; LblDeptName.Text = DisbursementLogic.GetListofDepartments().Where(x => x.DeptID == dL.DepartmentID).Select(x => x.DepartmentName).FirstOrDefault(); LblStatus.Text = dL.Status; switch (status) { case ("Collected"): { BtnCancelDis.Visible = false; LblCollectedBy.Visible = true; ImgSignature.ImageUrl = "http://localhost/Team12_SSIS/Images/" + "DL" + dL.DisbursementID + ".jpg"; ImgSignature.Visible = true; break; } case ("Pending Collection"): BtnCancelDis.Visible = true; break; default: BtnCancelDis.Visible = false; break; } }
public ActionResult Return(int?id) { if (!LoginService.IsAuthorizedRoles("clerk", "supervisor", "manager")) { return(RedirectToAction("Index", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UnitOfWork uow = new UnitOfWork(); DisbursementList disbursementList = uow.DisbursementListRepository.Get(filter: x => x.ID == id, includeProperties: "CreatedByStaff, ItemTransactions.Item, Department").FirstOrDefault(); if (disbursementList == null) { return(HttpNotFound()); } InventoryService inventoryService = new InventoryService(); Staff clerk = loginService.StaffFromSession; inventoryService.ProcessRejectedDisbursement(clerk, disbursementList.ID); disbursementList.Rejected(clerk); uow.DisbursementListRepository.Update(disbursementList); uow.Save(); return(RedirectToAction("Index")); }
public ActionResult ChangeCollectionPoint(string sessionId, DisbursementList disbursement, FormCollection frm) { bool timeErr = false; disbursement = DisbursementListService.GetDisbursementListByListId(disbursement.ListId); long selectedPoint = long.Parse(frm["collect"].ToString()); if (disbursement.CollectionPoint.PlacedId == selectedPoint) { return(RedirectToAction("RepDisbursementList", new { sessionId = sessionId, timeErr = timeErr })); } CollectionPoint c = DisbursementListService.GetCollectionPointByPlaceId(selectedPoint); DateTime selectedTime = disbursement.date.Date + c.Time; DateTime changeTime = DateTime.Now; TimeSpan timeDifference = selectedTime - changeTime; double minuteDifference = timeDifference.TotalMinutes; if (minuteDifference < 30) { timeErr = true; return(RedirectToAction("RepDisbursementList", new { sessionId = sessionId, timeErr = timeErr })); } disbursement.CollectionPoint = c; DisbursementListService.ChangeCollectionPoint(disbursement); return(RedirectToAction("RepDisbursementList", new { sessionId = sessionId, timeErr = timeErr })); }
public ActionResult RepDisbursementList(string sessionId, bool timeErr) { Employee emp = EmployeeService.GetUserBySessionId(sessionId); DisbursementList disbursementList = new DisbursementList(); List <DisbursementListDetails> disDetailList = new List <DisbursementListDetails>(); disbursementList = DisbursementListService.GetDisbursementListByDeptId(emp.DeptId); disbursementList.date = disbursementList.date.Date; if (disbursementList.ListId != 0) { disDetailList = DisbursementListService.ViewDisbursementDetails(disbursementList.ListId); } List <CollectionPoint> collectionPoints = DisbursementListService.GetAllCollectionPoints(); Dictionary <string, string> errDict = new Dictionary <string, string>(); if (timeErr) { errDict.Add("time", "To change the collection point, you need at least 30 minutes before the pick up time of selected one."); } ViewData["errDict"] = errDict; ViewData["disbursement"] = disbursementList; ViewData["disDetailList"] = disDetailList; ViewData["collectionPoints"] = collectionPoints; ViewData["sessionId"] = sessionId; ViewData["isRep"] = (emp.EmpRole == "REPRESENTATIVE"); return(View()); }