public ActionResult EditPartial(MainApplication model, FormCollection form) { model.CommissionMasterDetails.Status = "Active"; model.CommissionMasterDetails.ModifiedOn = DateTime.Now; if (model.CommissionMasterDetails.ItemCode != null) { model.CommissionMasterDetails.ItemName = _ItemService.GetDescriptionByItemCode(model.CommissionMasterDetails.ItemCode).itemName; } _CommissionService.Update(model.CommissionMasterDetails); var details = TempData["UnitList"] as IEnumerable <CommissionProduct>; foreach (var data in details) { var row = _CommissionProductService.GetSingleRowByCommCode(data.CommissionCode); _CommissionProductService.Delete(row); } int count = Convert.ToInt32(form["rowcount"]); for (int i = 1; i <= count; i++) { var product = "product" + i; var productamount = "productamount" + i; var productpercent = "productpercent" + i; if (form[product] != null && form[product] != "") { CommissionProduct unit = new CommissionProduct(); unit.CommissionCode = model.CommissionMasterDetails.CommissionCode; unit.EmployeeName = model.CommissionMasterDetails.EmployeeName; unit.UnitName = form[product]; unit.UnitAmount = form[productamount]; unit.UnitPercent = Convert.ToDouble(form[productpercent]); unit.Status = "Active"; unit.ModifiedOn = DateTime.Now; _CommissionProductService.Create(unit); } } TempData["Edit"] = "Edit"; string id = Encode(model.CommissionMasterDetails.CommissionId.ToString()); return(RedirectToAction("CommissionDetails/" + id, "Commission")); }