public string UpdateAdjustmentVoucher(string id, string action, string remarks) { AdjustmentVoucher adjustmentVoucher = findAdjustmentVoucher(id); string response = "Adjustment Voucher: [" + adjustmentVoucher.Id + "] request for " + action; if (adjustmentVoucher == null) { response += " has failed to locate"; } if (action == "approve") { bool res = updateInventory(adjustmentVoucher.InventoryId, adjustmentVoucher.qty); switch (res) { case true: response += " is sucessed."; adjustmentVoucher.status = Status.APPROVED; break; case false: response += " is denied as there is stock is less than the amount to be deducted."; break; } } if (action == "reject") { adjustmentVoucher.status = Status.REJECTED; response += " is sucessed."; } adjustmentVoucher.remarks = remarks; dbcontext.Update(adjustmentVoucher); dbcontext.SaveChanges(); return(response); }
public void AddItem(string userid, string itemid, int qty) { var oldcartItem = dbcontext.employeeCarts .Where(x => x.EmployeeId == userid && x.InventoryId == itemid) .FirstOrDefault(); if (oldcartItem == null) { var cartItem = new EmployeeCart() { Id = Guid.NewGuid().ToString(), EmployeeId = userid, InventoryId = itemid, Qty = qty, Inventory = dbcontext.inventories.SingleOrDefault(p => p.Id == itemid) }; dbcontext.employeeCarts.Add(cartItem); dbcontext.SaveChanges(); } else { oldcartItem.Qty = qty; dbcontext.Update(oldcartItem); dbcontext.SaveChanges(); } }
public void Handle(PersistEmployeeCommand command) { var employee = _context.Users.FirstOrDefault(x => string.Concat(x.FirstName, " ", x.LastName).ToUpper().Contains(command.FullName.ToUpper())); if (employee == null) { User newEmp = new User(); newEmp.Set(command.Persist.FirstName, command.Persist.LastName, command.Persist.JobId, command.Persist.UnitId); _context.Add(newEmp); } else { employee.Set(command.Persist.FirstName, command.Persist.LastName, command.Persist.JobId, command.Persist.UnitId); _context.Update(employee); } _context.SaveChanges(); }
public JsonResult SaveStatusToCompletedInDisb(string disId) { Disbursement d = dbcontext.disbursements.Where(x => x.Id == disId).FirstOrDefault(); d.status = DisbusementStatus.COMPLETED; dbcontext.Update(d); dbcontext.SaveChanges(); return(Json("1")); }
public void updateRequisition(string?userId, string requisitionId, ReqStatus?status, string?remarks) { Requisition requisition = findRequisition(requisitionId); // When authorization period expired, the default approver will be dept head. requisition.ApprovedEmployeeId = userId; requisition.Remarks = remarks; requisition.status = (ReqStatus)status; dbcontext.Update(requisition); dbcontext.SaveChanges(); }
// Unsure how is the Andriod going to pass the disbursed qty public void acknowledgeDisbursement(string disId, List <Disbursement_Detail> disDetailList) { Disbursement disbursement = findDisbursementById(disId); //Group the disbursement Details to according to itemId and sort by earliest to latest submition date Dictionary <string, List <DisbursementDetail> > list_disDetails = GroupSortDisDetailsByItemAndEarliestDate(disbursement); //Distribute disbursed qty as per items into respectively disbursement_detail & requisition_detail foreach (var d in disDetailList) { distributeItemQty(list_disDetails[d.itemId], d.disbursedQty); } List <Requisition> requisitions = disbursement.Requisitions.ToList(); //Update requisition while checking its fufilement foreach (var r in requisitions.Where(r => !reqSerivce.isPartialFufiled(r)).Select(r => r)) { r.status = ReqStatus.COMPLETED; } dbcontext.Update(requisitions); dbcontext.SaveChanges(); }
public string UpdateAdjustmentVoucher(string id, string action, string remarks) { AdjustmentVoucher adjustmentVoucher = findAdjustmentVoucher(id); string response = "Adjustment Voucher: " + adjustmentVoucher.Id; if (adjustmentVoucher == null) { response += " unable to locate"; } if (action == "approve") { adjustmentVoucher.status = Status.APPROVED; response += " approved"; } if (action == "reject") { adjustmentVoucher.status = Status.REJECTED; response += " rejected"; } adjustmentVoucher.remarks = remarks; dbcontext.Update(adjustmentVoucher); dbcontext.SaveChanges(); return(response); }