Esempio n. 1
0
        private async Task <IActionResult> CreateOrUpdate(ClientEditDto client)
        {
            var result = new ResultEntity();

            if (ModelState.IsValid)
            {
                if (string.IsNullOrWhiteSpace(client.HomePage))
                {
                    client.HomePage = "/Home/Index";
                }
                client.SetCreateOrUpdateInfo(CurrentUser.UserId);
                result = await _clientAppService.AddOrUpdateAsync(client);

                return(Json(result));
            }
            result.Message = ModelState.Values
                             .FirstOrDefault(a => a.ValidationState == ModelValidationState.Invalid)?.Errors.FirstOrDefault()
                             ?.ErrorMessage;

            return(Json(result));
        }