Exemplo n.º 1
0
        public ActionResult Edit(Models.Appliance.ApplianceModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var apiResponseModel = _applianceService.GetById(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, model.Id);

            if (apiResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                ViewBag.ErrorMessage     = apiResponseModel.ResultStatusMessage;
                ViewBag.ErrorMessageList = apiResponseModel.ErrorMessageList;
                return(View(model));
            }

            var appliance = apiResponseModel.Data;

            if (appliance == null)
            {
                return(View("_ErrorNotExist"));
            }

            appliance.Name    = model.Name;
            appliance.Barcode = model.Barcode;
            var apiEditResponseModel = _applianceService.Edit(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, appliance);

            if (apiEditResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                ViewBag.ErrorMessage     = apiEditResponseModel.ResultStatusMessage != null ? apiEditResponseModel.ResultStatusMessage : "Not Edited";
                ViewBag.ErrorMessageList = apiEditResponseModel.ErrorMessageList;
                return(View(model));
            }


            return(RedirectToAction(nameof(ApplianceController.List)));
        }