示例#1
0
        public IResult UpdateUserDetails(UserDetailForUpdateDto userDetailForUpdate)
        {
            var user = GetByUserId(userDetailForUpdate.Id).Data;

            if (!HashingHelper.VerifyPasswordHash(userDetailForUpdate.CurrentPassword, user.PasswordHash,
                                                  user.PasswordSalt))
            {
                return(new ErrorResult(Messages.PasswordError));
            }

            user.FirstName = userDetailForUpdate.FirstName;
            user.LastName  = userDetailForUpdate.LastName;
            user.Email     = userDetailForUpdate.Email;
            if (!string.IsNullOrEmpty(userDetailForUpdate.NewPassword))
            {
                byte[] passwordHash, passwordSalt;
                HashingHelper.CreatePasswordHash(userDetailForUpdate.NewPassword, out passwordHash, out passwordSalt);
                user.PasswordHash = passwordHash;
                user.PasswordSalt = passwordSalt;
            }

            _userDal.Update(user);

            var customer = _customerDal.Get(c => c.Id == userDetailForUpdate.CustomerId);

            customer.CompanyName = userDetailForUpdate.CompanyName;
            _customerDal.Update(customer);

            return(new SuccessResult(Messages.UserDetailsUpdated));
        }
示例#2
0
        public IActionResult UpdateUserDetails(UserDetailForUpdateDto userDetailForUpdate)
        {
            var result = _userService.UpdateUserDetails(userDetailForUpdate);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
示例#3
0
        public IResult UpdateUserDetails(UserDetailForUpdateDto userDetailForUpdate)
        {
            var user = GetById(userDetailForUpdate.Id).Data;

            if (!HashingHelper.VerifyPasswordHash(userDetailForUpdate.CurrentPassword, user.PasswordHash, user.PasswordSalt))
            {
                return(new ErrorResult());
            }

            user.FirstName = userDetailForUpdate.FirstName;
            user.LastName  = userDetailForUpdate.LastName;
            if (!string.IsNullOrEmpty(userDetailForUpdate.NewPassword))
            {
                byte[] passwordHash, passwordSalt;
                HashingHelper.CreatePasswordHash(userDetailForUpdate.NewPassword, out passwordHash, out passwordSalt);
                user.PasswordHash = passwordHash;
                user.PasswordSalt = passwordSalt;
            }

            _userDal.Update(user);

            var customer = _customerDal.Get(c => c.Id == userDetailForUpdate.CustomerId);

            customer.CompanyName = userDetailForUpdate.CompanyName;

            _customerDal.Update(customer);

            if (!string.IsNullOrEmpty(userDetailForUpdate.NationalIdentity))
            {
                var findeks = _findeksService.GetByCustomerId(userDetailForUpdate.CustomerId).Data;
                if (findeks == null)
                {
                    var newFindeks = new Findeks
                    {
                        CustomerId       = userDetailForUpdate.CustomerId,
                        NationalIdentity = userDetailForUpdate.NationalIdentity
                    };

                    _findeksService.Add(newFindeks);
                }
                else
                {
                    findeks.NationalIdentity = userDetailForUpdate.NationalIdentity;
                    var newFindeks = _findeksService.CalculateFindeksScore(findeks).Data;

                    _findeksDal.Update(newFindeks);
                }
            }

            return(new SuccessResult());
        }
示例#4
0
        public IResult UpdateUserDetails(UserDetailForUpdateDto userDetailForUpdateDto)
        {
            var user = GetByMail(userDetailForUpdateDto.Email).Data;

            byte[] passwordHash, passwordSalt;
            if (!HashingHelper.VerifyPasswordHash(userDetailForUpdateDto.CurrentPassword,
                                                  user.PasswordHash, user.PasswordSalt))
            {
                return(new ErrorResult("Hatalı parola"));
            }

            user.FirstName = userDetailForUpdateDto.FirstName;
            user.LastName  = userDetailForUpdateDto.LastName;
            HashingHelper.CreatePasswordHash(userDetailForUpdateDto.NewPassword, out passwordHash, out passwordSalt);
            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;
            _userDal.Update(user);
            var customer = _customerService.GetById(userDetailForUpdateDto.CustomerId).Data;

            customer.CompanyName = userDetailForUpdateDto.CompanyName;
            _customerService.Update(customer);

            var findex = _findexService.GetByCustomerId(userDetailForUpdateDto.CustomerId).Data;

            if (findex == null)
            {
                var newFindex = new Findex
                {
                    CustomerId = userDetailForUpdateDto.CustomerId
                };
                _findexService.Add(newFindex);
            }
            else
            {
                _findexService.Update(findex);
            }


            return(new SuccessResult(Messages.SuccessUpdated));
        }
示例#5
0
        public async Task <IActionResult> UpdateUserDetail(int id,
                                                           [FromBody] UserDetailForUpdateDto userDetailForUpdate)
        {
            if (userDetailForUpdate == null)
            {
                ModelState.AddModelError("Message", "Unable to locate payload for new request");
                return(BadRequest(ModelState));
            }

            var command = new ChangeUserDetailCommand(id, userDetailForUpdate.FirstName, userDetailForUpdate.LastName, userDetailForUpdate.Email, userDetailForUpdate.UserName, userDetailForUpdate.Active == Models.ValueTypes.YesNoValueType.Yes, userDetailForUpdate.AllowDatasetDownload == Models.ValueTypes.YesNoValueType.Yes);

            _logger.LogInformation(
                "----- Sending command: ChangeUserDetailCommand - {userId}",
                command.UserId);

            var commandResult = await _mediator.Send(command);

            if (!commandResult)
            {
                return(BadRequest("Command not created"));
            }

            return(Ok());
        }
 public IResult UpdateUserDetails(UserDetailForUpdateDto userDetailForUpdate)
 {
     throw new NotImplementedException();
 }