示例#1
0
        public IResult Update(Findeks findeks)
        {
            var newFindeks = CalculateFindeksScore(findeks).Data;

            _findeksDal.Update(newFindeks);
            return(new SuccessResult(Messages.FindeksUpdated));
        }
示例#2
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());
        }
 public IResult Update(Findeks findeks)
 {
     _findeksDal.Update(findeks);
     return(new SuccessResult());
 }
 public IResult Update(Findeks findeks)
 {
     _findeksDal.Update(findeks);
     return(new SuccessResult(Messages.FindeksUpdated));
 }