Exemple #1
0
        public ActionResult Add(Models.Location.AddViewModel modell)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.ErrorMessage = "Error.";
                return(View(modell));
            }

            Business.Models.Location.AddRequestModel location = new Business.Models.Location.AddRequestModel();
            location.Name = modell.Name;

            var apiResponseModel = _locationService.Add(location).Result;

            if (apiResponseModel.Status == ResultStatusCodeStatic.Success)
            {
                return(RedirectToAction(nameof(LocationController.List)));
            }
            else
            {
                ViewBag.ErrorMessage = apiResponseModel.Message != null ? apiResponseModel.Message : "Kaydedilemedi.";//todo: kulturel olacak NotSaved
                return(View(modell));
            }
        }
Exemple #2
0
        public ActionResult Edit(Models.Location.AddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var apiResponseModel = _locationService.GetById(model.Id).Result;

            if (apiResponseModel.Status != ResultStatusCodeStatic.Success)
            {
                ViewBag.ErrorMessage = apiResponseModel.Message;
                return(View(model));
            }

            var location = apiResponseModel.Data;

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

            AddRequestModel editModel = new AddRequestModel();

            editModel.Id   = location.Id;
            editModel.Name = model.Name;

            var apiEditResponseModel = _locationService.Edit(model.Id, editModel).Result;

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

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