public ActionResult DeleteUnitPost(string unitId, string identificationNo, string reason) { decimal paidCurtAmount = 0.00M; if (Session["PaidCurtAmount"] != null) { paidCurtAmount = (decimal)Session["PaidCurtAmount"]; } int loanId = (int)Session["deleteUnitloanId"]; UnitAccess ua = new UnitAccess(); UnitDeleteViewModel unitModel = new UnitDeleteViewModel(); int res = ua.DeleteUnit(loanId, unitId, paidCurtAmount, reason); if (res == 1) { if (Session["UnitDeleteList"] != null) { unitModel.DeleteUnits = (List <UnitDeleteModel>)Session["UnitDeleteList"]; var itemToRemove = unitModel.DeleteUnits.Single(r => r.UnitId == unitId); unitModel.DeleteUnits.Remove(itemToRemove); Session["UnitDeleteList"] = unitModel.DeleteUnits; } Log log = new Log(_userData.UserId, _userData.Company_Id, _userData.BranchId, loanId, "Delete Unit", "Delete Unit:" + identificationNo, DateTime.Now); int islog = (new LogAccess()).InsertLog(log); } else { return(new HttpStatusCodeResult(400, "Failed to delete unit, try again!")); } if (Session["DeleteSearchUnit"] != null) { DeleteSearchUnit seachUnit = (DeleteSearchUnit)Session["DeleteSearchUnit"]; unitModel = GetGridViewDetails(seachUnit.ViewType, seachUnit.Id, seachUnit.Year, seachUnit.Make, seachUnit.Model); } ViewBag.DeleteList = unitModel.DeleteUnits; return(PartialView("GridView", unitModel)); }
/* * * Frontend page : Delete units * Title : Get units from list which matching conditions * Designed : Kanishka Mahanama * User story : * Developed : Kanishka Mahanama * Date created : * */ public ActionResult GridView(int?viewType, string id, string year, string make, string model) { id = id.ToUpper(); DeleteSearchUnit seachUnit = new DeleteSearchUnit(); //Update conditions seachUnit.ViewType = viewType; seachUnit.Id = id; seachUnit.Year = year; seachUnit.Make = make; seachUnit.Model = model; //Update session Session["DeleteSearchUnit"] = seachUnit; // Get unit list which matching conditions UnitDeleteViewModel unitModel = GetGridViewDetails(viewType, id, year, make, model); //return model to partial view return(PartialView(unitModel)); }