Ejemplo n.º 1
0
        public async Task <IActionResult> SaveEntity(UserViewModel userVm)
        {
            if (!ModelState.IsValid)
            {
                IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(new BadRequestObjectResult(allErrors));
            }
            else
            {
                var userid = _generalFunctionController.Instance.getClaimType(User, CommonConstants.UserClaims.Key);

                if (Guid.TryParse(userid, out var guid))
                {
                    var chk = false;
                    userVm.LastupdatedName = _generalFunctionController.Instance.getClaimType(User, CommonConstants.UserClaims.FullName);
                    userVm.LastupdatedFk   = guid;
                    if (userVm.Id == null)
                    {
                        chk = await _userService.AddAddressBookAsync(userVm);
                    }
                    else
                    {
                        chk = await _userService.UpdateAddressBookAsync(userVm);
                    }

                    return(new OkObjectResult(chk));
                }
                return(new BadRequestResult());
            }
        }