Exemple #1
0
        public async Task <SOApiResult <bool> > UpdateBasicInfo(UserBasicInfoDto basicInfoDto)
        {
            string      urlPath   = "/UserApi/UpdateBasicInfo";
            string      token     = WebAdminHelper.GetToken(_httpContextAccessor);
            SOApiParams apiParams = new SOApiParams(_httpClientFactory, token, urlPath, basicInfoDto);;

            return(await SOApiHelper.ExecutePutMethod <bool>(apiParams));
        }
        public async Task <IActionResult> UpdateBasicInfo([FromBody] UserBasicInfoDto basicInfoDto)
        {
            SOApiResult <bool> result = await _userApiService.UpdateBasicInfo(basicInfoDto);

            if (result.IsSucceed)
            {
                return(Ok());
            }
            return(BadRequest(result.Message));
        }
        public async Task <SOApiResult <bool> > UpdateBasicInfo(UserBasicInfoDto basicInfoDto)
        {
            SOApiResult <bool> result = _repository.SUSER_REPOSITORY.VerifyUserInfo(new UserDto()
            {
                UserId = basicInfoDto.UserId,
                Email  = basicInfoDto.Email
            });

            if (result.IsSucceed)
            {
                return(await _repository.SUSER_REPOSITORY.UpdateBasicInfo(basicInfoDto));
            }
            return(result);
        }
        public async Task <IActionResult> Update(UserBasicInfoDto basicInfoDto)
        {
            if (ModelState.IsValid)
            {
                SOApiResult <bool> result = await _userService.UpdateBasicInfo(basicInfoDto);

                if (result.IsSucceed)
                {
                    return(RedirectToAction("GetUserList"));
                }
                else
                {
                    ModelState.AddModelError("Exception", result.Message);
                }
            }
            //Log Here
            return(View("UserBasicInfo", basicInfoDto));
        }
        public async Task <IActionResult> Update(Guid userId)
        {
            UserBasicInfoDto      basicInfoDto = new UserBasicInfoDto();
            SOApiResult <UserDto> result       = await _userService.GetByUserId(userId);

            if (!result.IsSucceed)
            {
                //Log Here
            }
            else
            {
                UserDto userDto = result.ReturnedData;
                basicInfoDto.UserId   = userDto.UserId;
                basicInfoDto.FullName = userDto.FullName;
                basicInfoDto.DOB      = userDto.DOB;
                basicInfoDto.Email    = userDto.Email;
            };
            return(View("UserBasicInfo", basicInfoDto));
        }
        public async Task <SOApiResult <bool> > UpdateBasicInfo(UserBasicInfoDto basicInfoDto)
        {
            S_USER existingUser = DataSet.FirstOrDefault(u => !u.IS_DELETED && u.Id == basicInfoDto.UserId);

            if (existingUser != null)
            {
                existingUser.FULL_NAME = basicInfoDto.FullName;
                existingUser.DOB       = basicInfoDto.DOB;
                existingUser.Email     = basicInfoDto.Email;
                var result = await Repository.SysApi_UserManager.UpdateAsync(existingUser);

                if (result.Succeeded)
                {
                    return(new SOApiSuccessResult <bool>());
                }
                return(new SOApiErrorResult <bool>("Update-User failed " + string.Join("", result.Errors.Select(e => e.Description).ToList())));
            }
            ;
            return(new SOApiErrorResult <bool>("User not found"));
        }