public async Task <ActionResult> UpdateFacility(int facilityId) { try { // Load service information DataModel model = new DataModel(); Facility facility = await model.LoadFacilityById(facilityId); if (facility != null) { model.FacilityName = facility.Facility_Name; model.TypeID = facility.Facility_Type.Value; model.FacilityID = facilityId; } // Load list of service type facilityTypeList = await ServiceFacilityUtil.LoadFacilityTypeAsync(); ViewBag.FacilityTypeList = new SelectList(facilityTypeList, Constants.TypeID, Constants.TypeName); return(PartialView(Constants.UpdateFacilityAction, model)); } catch (Exception exception) { LoggingUtil.LogException(exception); return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController)); } }
public async Task <ActionResult> AddFacility() { try { // Load list of service type facilityTypeList = await ServiceFacilityUtil.LoadFacilityTypeAsync(); ViewBag.FacilityTypeList = new SelectList(facilityTypeList, Constants.TypeID, Constants.TypeName); return(PartialView(Constants.AddFacilityAction)); } catch (Exception exception) { LoggingUtil.LogException(exception); return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController)); } }
public async Task <ActionResult> FacilityList(DataModel model, int?page) { IPagedList <SP_TAKE_FACILITY_AND_TYPEResult> pagedFacilityList = null; try { // Load list of service type facilityTypeList = await ServiceFacilityUtil.LoadFacilityTypeAsync(); ViewBag.FacilityTypeList = new SelectList(facilityTypeList, Constants.TypeID, Constants.TypeName); // Check if page parameter is null if (page == null) { page = 1; } #region Load data // Load list of service List <SP_TAKE_FACILITY_AND_TYPEResult> facilityList = new List <SP_TAKE_FACILITY_AND_TYPEResult>(); if (model.IsPostBack == false) { facilityList = await model.LoadListOfFacility(null, 0, true); ViewBag.CurrentStatus = true; } else { facilityList = await model.LoadListOfFacility( model.FacilityName, model.TypeID, model.IsActive); ViewBag.CurrentStatus = model.IsActive; } #endregion #region Display notification // Pass value of previous adding facility to view (if any) if (TempData[Constants.ProcessInsertData] != null) { ViewBag.AddStatus = (int)TempData[Constants.ProcessInsertData]; } // Pass value of previous updating service to view (if any) if (TempData[Constants.ProcessUpdateData] != null) { ViewBag.UpdateStatus = (int)TempData[Constants.ProcessUpdateData]; } // Pass value of previous updating service status to view (if any) if (TempData[Constants.ProcessStatusData] != null) { ViewBag.ChangeStatus = (int)TempData[Constants.ProcessStatusData]; } #endregion // Handle query string NameValueCollection queryString = System.Web.HttpUtility.ParseQueryString(Request.Url.Query); queryString.Remove(Constants.PageUrlRewriting); ViewBag.Query = queryString.ToString(); // Return value to view pagedFacilityList = facilityList.ToPagedList(page.Value, Constants.PageSize); return(View(pagedFacilityList)); } catch (Exception exception) { LoggingUtil.LogException(exception); return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController)); } }