Ejemplo n.º 1
0
        public async Task <IActionResult> CreateAsync(CreateViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                ViewData["ErrorMessage"] = "Invalid form submission.";
                return(PartialView("_CreateLocation", viewModel));
            }

            LocationResponse _Response = await __LocationManager.CreateAsync(viewModel.ToRequest());

            if (!_Response.Success)
            {
                ViewData["ErrorMessage"] = _Response.ErrorMessage;
                return(CreateModal());
            }
            else
            {
                ViewData["SuccessMessage"] = $"{GlobalConstants.SUCCESS_ACTION_PREFIX} created {ENTITY_NAME}";
            }

            return(Json(new { success = $"{GlobalConstants.SUCCESS_ACTION_PREFIX} added {ENTITY_NAME}" }));
        }