Ejemplo n.º 1
0
        public IResult Update(Findeks findeks)
        {
            var newFindeks = CalculateFindeksScore(findeks).Data;

            _findeksDal.Update(newFindeks);
            return(new SuccessResult(Messages.FindeksUpdated));
        }
Ejemplo n.º 2
0
        public async Task <IResult> Update(Findeks findeks)
        {
            var newFindeks = CalculateFindeksScore(findeks).Data;
            await _findeksDal.UpdateAsync(newFindeks);

            return(new SuccessResult(Messages.FindeksUpdated));
        }
Ejemplo n.º 3
0
        public IResult Add(Findeks findeks)
        {
            var calculatedFindex = CalculateFindeksScore(findeks);

            _findeksDal.Add(calculatedFindex.Data);
            return(new SuccessResult(Messages.FindexAdded));
        }
Ejemplo n.º 4
0
        public IResult Add(Findeks findeks)
        {
            var newFindeks = CalculateFindeksScore(findeks).Data;

            _findeksDal.Add(newFindeks);
            return(new SuccessResult(Messages.Added));
        }
Ejemplo n.º 5
0
        public IDataResult <FindeksDto> GetUserFindeks(Findeks findeks)
        {
            var random = new Random();

            return(new SuccessDataResult <FindeksDto>(new FindeksDto
            {
                FindeksScore = random.Next(1, 1900)
            }));
        }
Ejemplo n.º 6
0
        public IActionResult Delete(Findeks findeks)
        {
            var result = _findexService.Delete(findeks);

            if (result.Success == true)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Ejemplo n.º 7
0
        public IActionResult GetFindeks([FromBody] Findeks findeks)
        {
            var result = _userService.GetUserFindeks(findeks);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Ejemplo n.º 8
0
        public IActionResult Update(Findeks findeks)
        {
            var result = _findeksService.Update(findeks);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Ejemplo n.º 9
0
        public IActionResult GetAll(Findeks findeks)
        {
            var result = _findeksService.GetAll();

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Ejemplo n.º 10
0
        public IDataResult <Findeks> GetUserFindeks(Findeks findeks)
        {
            Random rnd         = new Random();
            var    userFindeks = new Findeks
            {
                Tc          = findeks.Tc,
                DateYear    = findeks.DateYear,
                UserFindeks = rnd.Next(0, 1900)
            };

            return(new SuccessDataResult <Findeks>(userFindeks));
        }
        public IDataResult <Findeks> Add(Findeks findeks)
        {
            var nationalToCheck = GetFindeksByNationalId(findeks.NationalIdentity);

            if (nationalToCheck.Data == null)
            {
                Random value = new Random();
                findeks.FindeksValue = (short)value.Next(0, 1901);
                _findeksDal.Add(findeks);
                return(new SuccessDataResult <Findeks>(findeks, Messages.FindexAdded));
            }
            return(new ErrorDataResult <Findeks>(Messages.UserHasFindexAlreadyExist));
        }
Ejemplo n.º 12
0
        public IActionResult Add(Findeks findeks)
        {
            var result = _findeksService.Add(findeks);

            if (result.Success)
            {
                return(Ok(result));
            }
            else
            {
                return(BadRequest(result.Message));
            }
        }
Ejemplo n.º 13
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());
        }
Ejemplo n.º 14
0
        public IDataResult <int> CalculateFindeksRating()
        {
            Findeks findeks = new Findeks
            {
                CreditProductRepayments = new Random().Next(666), // 665
                CurrentAccountsAndDebts = new Random().Next(666), // 665
                LoanUsageIntensity      = new Random().Next(191), // 190
                NewLoansTaken           = new Random().Next(210), // 209
                OtherFactors            = new Random().Next(172), // 171
                                                                  // Equal to 1900 (1900 is max value of findeks rating)
            };

            int creditProductRepayments = findeks.CreditProductRepayments;
            int currentAccountsAndDebts = findeks.CurrentAccountsAndDebts;
            int loanUsageIntensity      = findeks.LoanUsageIntensity;
            int newLoansTaken           = findeks.NewLoansTaken;
            int otherFactors            = findeks.OtherFactors;

            int findeksRating = creditProductRepayments + currentAccountsAndDebts + loanUsageIntensity + newLoansTaken + otherFactors;

            findeks.MinimumFindeksRating = findeksRating;

            return(new SuccessDataResult <int>(findeksRating, Messages.FindeksRatingCalculated));
        }
Ejemplo n.º 15
0
 public IDataResult <Findeks> CalculateFindeksScore(Findeks findeks)
 {
     findeks.FindeksScore = new Random().Next(0, 1901);
     return(new SuccessDataResult <Findeks>(findeks));
 }
Ejemplo n.º 16
0
 public IResult Update(Findeks findeks)
 {
     _findeksDal.Update(findeks);
     return(new SuccessResult());
 }
Ejemplo n.º 17
0
 public IResult Delete(Findeks findeks)
 {
     _findeksDal.Delete(findeks);
     return(new SuccessResult());
 }
Ejemplo n.º 18
0
 public IResult Add(Findeks findeks)
 {
     _findeksDal.Add(findeks);
     return(new SuccessResult());
 }
Ejemplo n.º 19
0
        public IDataResult <Findeks> CalculateFindeksScore(Findeks findeks) // Fake
        {
            findeks.Score = (short)new Random().Next(0, 1901);

            return(new SuccessDataResult <Findeks>(findeks));
        }
Ejemplo n.º 20
0
 public IResult Update(Findeks findeks)
 {
     _findeksDal.Update(findeks);
     return(new SuccessResult(Messages.FindeksUpdated));
 }
Ejemplo n.º 21
0
 public IResult Add(Findeks findeks)
 {
     _findeksDal.Add(findeks);
     return(new SuccessResult(Messages.FindeksAdded));
 }
Ejemplo n.º 22
0
        public IResult Delete(Findeks findeks)
        {
            _findeksDal.Delete(findeks);

            return(new SuccessResult(Messages.DeletedFindex));
        }
Ejemplo n.º 23
0
        public async Task <IResult> Delete(Findeks findeks)
        {
            await _findeksDal.DeleteAsync(findeks);

            return(new SuccessResult(Messages.FindeksDeleted));
        }