Exemple #1
0
        // GET: OfferAdvise
        public async Task <ActionResult> Index()
        {
            var model = new OfferAdviseModel();

            try
            {
                //Call API Provider
                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                List <string> listPara = new List <string> {
                    "patientId", "status"
                };
                var strUrl = APIProvider.APIGenerator(controllerName, listPara, true, _userSession.UserId, (byte)EnumOfferAdviseStatus.ViewAll);
                var list   = await APIProvider.Authorize_Get <List <OfferAdviseViewModel> >(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Get);

                model.lstOfferAdviseViewModel = list;
                model.OfferAdviseViewModel    = new OfferAdviseViewModel();
            }
            catch (HttpException ex)
            {
                Logger.LogError(ex);
                int statusCode = ex.GetHttpCode();
                if (statusCode == 401)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(FuntionType.Department, APIConstant.ACTION_ACCESS);
                    return(new HttpUnauthorizedResult());
                }

                throw ex;
            }
            return(View(model));
        }
Exemple #2
0
        public async Task <ActionResult> Create(OfferAdviseViewModel model)
        {
            model.PatientId = _userSession.UserId;
            model.Status    = (byte)EnumOfferAdviseStatus.New;
            if (ModelState.IsValid)
            {
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_INSERT);
                var    result = await APIProvider.Authorize_DynamicTransaction <OfferAdviseViewModel, int>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Insert);

                if (result > 0)
                {
                    ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                var offeradvise = new OfferAdviseModel();

                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                List <string> listPara = new List <string> {
                    "patientId", "status"
                };
                var strUrl = APIProvider.APIGenerator(controllerName, listPara, true, _userSession.UserId, (byte)EnumOfferAdviseStatus.ViewAll);
                var list   = await APIProvider.Authorize_Get <List <OfferAdviseViewModel> >(_userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Get);

                offeradvise.lstOfferAdviseViewModel = list;

                offeradvise.OfferAdviseViewModel = model;

                ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                return(View("Index", offeradvise));
            }
        }