public ActionResult Disbursements(List <RetrievalItem> items) { List <AdjustmentDetail> adjustmentDetails = new List <AdjustmentDetail>(); bool valid = true; foreach (var i in items) { if (i.AllocatedQuantity > i.ActualQuantity) { AdjustmentDetail detail = new AdjustmentDetail() { Count = (i.StockQuantity - i.ActualQuantity), Item = new Item() { ItemId = i.ItemId } }; adjustmentDetails.Add(detail); } else if (i.AllocatedQuantity == i.ActualQuantity) { } else { valid = false; break; } } if (valid != false) { if (adjustmentDetails.Count > 0) { int userId = Convert.ToInt32(RouteData.Values["userId"]); User u = new User() { UserId = userId }; Adjustment ad = AdjustmentDao.InsertAdjustment(adjustmentDetails, u); AdjustmentDao.CalculateAdjustmentCost(ad); ItemDao.UpdateStockForAdjustment(adjustmentDetails); } DisbursementDao.GenerateDisbursements(items); Task.Run(() => EmailUtility.SendEmailForItemsPickUp()); return(RedirectToAction("Retrieval", "Stationery")); } else { return(RedirectToAction("Retrieval", "Stationery")); } }