public ActionResult PartialRequiredItem() { CustomerRequirment CustomerRequirment = new CustomerRequirment(); List <CustomerRequirment> lstCustomerRequirment = new List <CustomerRequirment>(); TryUpdateModel(CustomerRequirment); if (TempData["lstCustomerRequirment"] == null) { TempData["lstCustomerRequirment"] = lstCustomerRequirment; } else { lstCustomerRequirment = TempData["lstCustomerRequirment"] as List <CustomerRequirment>; } if (ModelState.IsValid) { if (!lstCustomerRequirment.Exists(e => e.ItemId == CustomerRequirment.ItemId)) { CustomerRequirment.ItemName = new clsM_Item().GetItemByItemId(CustomerRequirment.ItemId).ItemName; CustomerRequirment.GradeDesc = new clsM_Grade().GetItemGradeByGradeId(CustomerRequirment.GradeId).GradeDescription; CustomerRequirment.UOMDesc = new clsM_UOM().GetUnitofMeasurementFromId(CustomerRequirment.UOMId).UOMName; lstCustomerRequirment.Add(CustomerRequirment); } else { TempData["Message"] = new MessageBox { CssClassName = ".alert-warning", Title = "Warning!", Message = "This item exist in the list." } }; } else { TempData["Message"] = new MessageBox { CssClassName = ".alert-warning", Title = "Warning!", Message = "Missing some details." } }; int Row = 0; lstCustomerRequirment.ForEach(e => e.RequirementId = (Row = Row + 1)); TempData["lstCustomerRequirment"] = lstCustomerRequirment; return(PartialView("_PartialItemDetails", lstCustomerRequirment)); }
public ActionResult Create_Post() { CustomerRequirment CustomerRequirment = new CustomerRequirment(); List <CustomerRequirment> lstCustomerRequirment = new List <CustomerRequirment>(); if (TempData["lstCustomerRequirment"] == null) { TempData["lstCustomerRequirment"] = lstCustomerRequirment; } else { lstCustomerRequirment = TempData["lstCustomerRequirment"] as List <CustomerRequirment>; } TryUpdateModel(CustomerRequirment); if (lstCustomerRequirment.Count > 0) { //Update customer and create date lstCustomerRequirment.ForEach(e => e.CustomerId = 1); lstCustomerRequirment.ForEach(e => e.CreatedBy = commonFunctions.GetTransactionEmployeeCode()); ErrorMsg = new clsT_CustomerRequirment().SaveCustomerRequirment(lstCustomerRequirment, out RequestNo); //Error Found if (!string.IsNullOrEmpty(ErrorMsg)) { TempData["Message"] = new MessageBox { CssClassName = ".alert-danger", Title = "Error!", Message = "Transaction was rollback.Try again." }; ViewBag.Category = GetCategories(); ViewBag.Customer = GetCustomer(); ViewBag.UOM = getUOM(); TempData["lstCustomerRequirment"] = lstCustomerRequirment; return(View(lstCustomerRequirment)); } else { TempData["lstCustomerRequirment"] = null; TempData["Message"] = new MessageBox { CssClassName = ".alert-success", Title = "Success!", Message = "Your Customer Requirement No: " + RequestNo }; return(RedirectToAction("Create")); } } else { ViewBag.Category = GetCategories(); ViewBag.Customer = GetCustomer(); ViewBag.UOM = getUOM(); TempData["Message"] = new MessageBox { CssClassName = ".alert-warning", Title = "Warning!", Message = "Request details not found." }; TempData["lstCustomerRequirment"] = lstCustomerRequirment; return(View(lstCustomerRequirment)); } }