Example #1
0
        public async Task <ActionResult> UpdateService(int serviceId)
        {
            try
            {
                // Load service information
                DataModel model   = new DataModel();
                Service   service = await model.LoadSerivceById(serviceId);

                if (service != null)
                {
                    model.ServiceName = service.Service_Name;
                    model.TypeID      = service.Service_Type.Value;
                    model.ServiceID   = serviceId;
                }

                // Load list of service type
                serviceTypeList = await ServiceFacilityUtil.LoadServiceTypeAsync();

                ViewBag.ServiceTypeList = new SelectList(serviceTypeList, Constants.TypeID, Constants.TypeName);

                return(PartialView(Constants.UpdateServiceAction, model));
            }
            catch (Exception exception)
            {
                LoggingUtil.LogException(exception);
                return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController));
            }
        }
Example #2
0
        public async Task <ActionResult> AddService()
        {
            try
            {
                // Load list of service type
                serviceTypeList = await ServiceFacilityUtil.LoadServiceTypeAsync();

                ViewBag.ServiceTypeList = new SelectList(serviceTypeList, Constants.TypeID, Constants.TypeName);

                return(PartialView(Constants.AddServiceAction));
            }
            catch (Exception exception)
            {
                LoggingUtil.LogException(exception);
                return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController));
            }
        }
Example #3
0
        public async Task <ActionResult> ServiceList(DataModel model, int?page)
        {
            IPagedList <SP_TAKE_SERVICE_AND_TYPEResult> pagedServiceList = null;

            try
            {
                // Load list of service type
                serviceTypeList = await ServiceFacilityUtil.LoadServiceTypeAsync();

                ViewBag.ServiceTypeList = new SelectList(serviceTypeList, 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_SERVICE_AND_TYPEResult> serviceList =
                    new List <SP_TAKE_SERVICE_AND_TYPEResult>();
                if (model.IsPostBack == false)
                {
                    serviceList = await model.LoadListOfService(null, 0, true);

                    ViewBag.CurrentStatus = true;
                }
                else
                {
                    serviceList = await model.LoadListOfService(
                        model.ServiceName, model.TypeID, model.IsActive);

                    ViewBag.CurrentStatus = model.IsActive;
                }

                #endregion

                #region Display notification

                // Pass value of previous adding service 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
                pagedServiceList = serviceList.ToPagedList(page.Value, Constants.PageSize);
                return(View(pagedServiceList));
            }
            catch (Exception exception)
            {
                LoggingUtil.LogException(exception);
                return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController));
            }
        }