Exemplo n.º 1
0
 public MovieController(MovieService movieService, CreditService creditService, PersonService personService, PersonImagesService personImagesService)
 {
     _movieService        = movieService;
     _creditService       = creditService;
     _personImagesService = personImagesService;
     _personService       = personService;
 }
        public async Task OnLoadAsync(INavigationParameters parameters, int attempt = 0)
        {
            try
            {
                var data = await CreditService.GetAsync();

                Credits.Clear();

                foreach (var item in data.OrderBy(x => x.CreditType))
                {
                    Credits.Add(new Credit
                    {
                        Title        = item.Title,
                        CreditType   = (CreditType)item.CreditType,
                        Description  = item.Description,
                        Website      = item.Website,
                        IncludeTitle = item.IncludeTitle,
                        Logo         = ImageSource.FromStream(() => new MemoryStream(item.Logo))
                    });
                }
            }
            catch (Exception)
            {
                await ErrorRetryManager.HandleRetryAsync(this, parameters, attempt);
            }
        }
Exemplo n.º 3
0
        public void CalculateDeifferentCredit()
        {
            var unitOfWork = new Mock <IUnitOfWork>();

            var creditDTO = GetCreditDto();
            var credit    = GetCredit();

            unitOfWork.Setup(repo => repo.Credits.Get(GetCreditDto().Id)).Returns(credit);
            unitOfWork.Setup(repo => repo.SpecialPercentagePeriods.AddRange(new List <SpecialPercentagePeriod>())).Returns(() => null);
            unitOfWork.Setup(repo => repo.MonthPayments.AddRange(new List <MonthPayment>())).Returns(() => null);
            unitOfWork.Setup(repo => repo.Complete()).Returns(() => Task.Run(() => 1));

            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutomapperProfile());
            });
            var mapper = mockMapper.CreateMapper();


            var creditService = new CreditService(unitOfWork.Object, mapper);

            var result = creditService.Calculate(creditDTO);

            var firstPersantege = GetCreditDto().SpecialPersentages.Count > 0 ? GetCreditDto().SpecialPersentages.First().MonthPercentage : GetCreditDto().BasePercenteges;

            Assert.True(result.Result.IsSuccess);

            Assert.Equal(GetCreditDto().MonthsCount, result.Result?.ReturnValue?.MonthPayments.Count());

            var percentegePayment = GetCreditDto().Amount *firstPersantege / 100 / 12;

            Assert.Equal(percentegePayment, result.Result.ReturnValue.MonthPayments.FirstOrDefault()?.PersentegesPyment);
        }
Exemplo n.º 4
0
        public async Task GetBalance_ReturnsPositiveNumber_Test()
        {
            var creditService = new CreditService(new FakeOdorikCredentials());

            var result = await creditService.GetBalanceAsync();

            Assert.IsTrue(result > 0);
        }
Exemplo n.º 5
0
        public ClientsController(ClientService clientService, CreditService creditService, ExtractService extractService, IHttpContextAccessor httpContextAccessor)
        {
            _clientService       = clientService;
            _creditService       = creditService;
            _extractService      = extractService;
            _httpContextAccessor = httpContextAccessor;

            userId = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
        }
        public void Setup()
        {
            _fixture = new Fixture();
            _mockCreditRepository   = new Mock <ICreditRepository>();
            _mockLimitCalculator    = new Mock <ILimitCalculatorService>();
            _mockCreditScoreService = new Mock <ICreditScoreService>();

            _sut = new CreditService(_mockCreditScoreService.Object, _mockLimitCalculator.Object, _mockCreditRepository.Object);
        }
Exemplo n.º 7
0
        public ActionResult WorkPage(int creditId)
        {
            var credit = CreditService.Get(creditId);

            return(View(new AtmAccountModel()
            {
                CreditId = credit.Id, Amount = credit.MainAccount.Balance
            }));
        }
Exemplo n.º 8
0
        public GeneralResponse AddCreditService(AddCreditServiceRequestOld request)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                CreditService creditService = new CreditService();
                creditService.ID                = Guid.NewGuid();
                creditService.CreateDate        = PersianDateTime.Now;
                creditService.CreateEmployee    = _employeeRepository.FindBy(request.CreateEmployeeID);
                creditService.CreditServiceCode = request.CreditServiceCode;
                creditService.Discontinued      = request.Discontinued;
                creditService.ExpDays           = request.ExpDays;
                creditService.Imposition        = request.Imposition;
                creditService.MaxDiscount       = request.MaxDiscount;
                creditService.Network           = this._networkRepository.FindBy(request.NetworkID);
                creditService.PurchaseUnitPrice = request.PurchaseUnitPrice;
                creditService.ResellerUnitPrice = request.ResellerUnitPrice;
                creditService.ServiceName       = request.ServiceName;
                creditService.UnitPrice         = request.UnitPrice;
                creditService.Note              = request.Note;
                creditService.Discontinued      = request.Discontinued;
                creditService.SortOrder         = GetSortOrder();
                creditService.RowVersion        = 1;

                // Validation
                if (creditService.GetBrokenRules().Count() > 0)
                {
                    foreach (BusinessRule businessRule in creditService.GetBrokenRules())
                    {
                        response.ErrorMessages.Add(businessRule.Rule);
                    }

                    return(response);
                }

                _creditServiceRepository.Add(creditService);
                _uow.Commit();
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null && ex.InnerException.Message.Substring(0, 177) == @"The INSERT statement conflicted with the CHECK constraint ""CK_CreditService"". The conflict occurred in database ""Saman"", table ""Store.CreditService"", column 'CreditServiceCode'.")
                {
                    response.ErrorMessages.Add("MustBeBegin3000Key");
                }
                else
                {
                    response.ErrorMessages.Add(ex.Message);
                    if (ex.InnerException != null)
                    {
                        response.ErrorMessages.Add(ex.InnerException.Message);
                    }
                }
            }

            return(response);
        }
Exemplo n.º 9
0
        public GeneralResponse DeleteCreditServices(IEnumerable <DeleteRequest> requests)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                CreditService creditService = new CreditService();

                foreach (DeleteRequest request in requests)
                {
                    if (creditService != null)
                    {
                        try
                        {
                            _creditServiceRepository.RemoveById(request.ID);

                            ////response.success = true;
                        }
                        catch (Exception ex)
                        {
                            response.ErrorMessages.Add(ex.Message);

                            if (ex.Message.Substring(0, 40) == "Cannot insert the value NULL into column" ||
                                ex.InnerException.Message.Substring(0, 40) == "Cannot insert the value NULL into column")
                            {
                                response.ErrorMessages.Clear();
                                response.ErrorMessages.Add("CanNotDeleteEmployeeKey");
                            }
                            else
                            {
                                if (ex.InnerException != null)
                                {
                                    response.ErrorMessages.Add("FIRST INNER EXPCEPTION: " + ex.InnerException.Message);
                                    if (ex.InnerException.InnerException != null)
                                    {
                                        response.ErrorMessages.Add("SECOND INNER EXPCEPTION: " + ex.InnerException.InnerException.Message);
                                    }
                                }
                            }
                        }
                    }
                }
                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Exemplo n.º 10
0
 public CreditController(ParserService parserService, BankService bankService, IMapper mapper, ApplicationDbContext context, CreditService creditService, RecomendationSystem recomendation, UserManager <User> userManager, LikeCreditService likeCreditService)
 {
     this.parserService     = parserService;
     this.bankService       = bankService;
     this.creditService     = creditService;
     this.mapper            = mapper;
     this.context           = context;
     this.likeCreditService = likeCreditService;
     this._recomendation    = recomendation;
     this._userManager      = userManager;
 }
Exemplo n.º 11
0
        public CreditServiceTests()
        {
            creditFactoryMock = new Mock <ICreditFactory>();
            credit            = new Mock <ICredit>();
            credit.Setup(e => e.IsApproved).Returns(true);
            credit.Setup(e => e.InterestValue).Returns(1);
            credit.Setup(e => e.TotalValue).Returns(1001);

            creditFactoryMock.Setup(e => e.Create(input.CreditType, input.Value, input.QtdInstallments, input.FirstDueDate)).Returns(credit.Object);

            _sut = new CreditService(creditFactoryMock.Object);
        }
Exemplo n.º 12
0
        public CreditServiceTests()
        {
            service = new CreditService(new PorticoConfig {
                SecretApiKey = "skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w"
            });

            card = new CreditCardData {
                Number   = "4111111111111111",
                ExpMonth = 12,
                ExpYear  = 2015,
                Cvn      = "123"
            };
        }
Exemplo n.º 13
0
        public AccountReportModel GenerateAccountReport()
        {
            AccountReportModel result = new AccountReportModel();

            {
                result.DevelopmentFundAccount =
                    Mapper.Map <ORMLibrary.Account, AccountModel>(AccountService.GetDevelopmentFundAccount());
                result.CashdeskAccount =
                    Mapper.Map <ORMLibrary.Account, AccountModel>(AccountService.GetCashDeskAccount());
                result.Credits  = CreditService.GetAll();
                result.Deposits = DepositService.GetAll();
            }
            return(result);
        }
Exemplo n.º 14
0
        public CreditServiceTests()
        {
            service = new CreditService(new GatewayConfig {
                SecretApiKey = "skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w",
                ServiceUrl   = "https://cert.api2.heartlandportico.com"
            });

            card = new CreditCardData {
                Number   = "4111111111111111",
                ExpMonth = 12,
                ExpYear  = 2015,
                Cvn      = "123"
            };
        }
Exemplo n.º 15
0
        public MoveResponse MoveDown(MoveRequest request)
        {
            MoveResponse response = new MoveResponse();

            // Current Agency is the Request
            CreditService currentCreditService = new CreditService();

            currentCreditService = _creditServiceRepository.FindBy(request.ID);

            // Find the Previews Agency
            CreditService nextCreditService = new CreditService();

            try
            {
                nextCreditService = _creditServiceRepository.FindAll()
                                    .Where(s => s.SortOrder > currentCreditService.SortOrder)
                                    .OrderBy(s => s.SortOrder)
                                    .First();
            }
            catch (Exception ex)
            {
            }

            if (currentCreditService != null && nextCreditService != null)
            {
                try
                {
                    // replacing SortOrders
                    int current  = currentCreditService.SortOrder;
                    int previews = nextCreditService.SortOrder;

                    currentCreditService.SortOrder = previews;
                    nextCreditService.SortOrder    = current;

                    _creditServiceRepository.Save(currentCreditService);
                    _creditServiceRepository.Save(nextCreditService);
                    _uow.Commit();
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                    return(response);
                }

                ////response.success = true;
            }

            return(response);
        }
Exemplo n.º 16
0
 public ActionResult Create(CreateCreditModel credit)
 {
     if (ModelState.IsValid)
     {
         try
         {
             CreditService.Create(Mapper.Map <CreateCreditModel, CreditModel>(credit), credit.CreateCreditCard);
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex.Message);
             return(View(credit.ToCreateCreditModel(PlanOfCreditService, ClientService)));
         }
     }
     return(View(credit.ToCreateCreditModel(PlanOfCreditService, ClientService)));
 }
Exemplo n.º 17
0
        public GetCreditServiceResponse GetCreditService(GetRequest request)
        {
            GetCreditServiceResponse response = new GetCreditServiceResponse();

            try
            {
                CreditService     creditService     = new CreditService();
                CreditServiceView creditServiceView = creditService.ConvertToCreditServiceView();

                creditService = _creditServiceRepository.FindBy(request.ID);
                if (creditService != null)
                {
                    creditServiceView = creditService.ConvertToCreditServiceView();
                }

                response.CreditServiceView = creditServiceView;
            }
            catch (Exception ex)
            {
            }

            return(response);
        }
Exemplo n.º 18
0
 public ActionResult CloseCredit(int creditId)
 {
     CreditService.CloseCredit(creditId);
     return(RedirectToAction("Details", new { CreditId = creditId }));
 }
 public CreditDetailsController(CreditService creditService)
 {
     this.creditService = creditService;
 }
Exemplo n.º 20
0
        public ActionResult PaymentSchedule(int creditId)
        {
            var schedule = CreditService.GetPaymentSchedule(creditId);

            return(View("Schedule", Mapper.Map <PlanOfPaymentModel, PlanOfPayment>(schedule)));
        }
Exemplo n.º 21
0
 public ActionResult PayPercents(int creditId)
 {
     CreditService.PayPercents(creditId);
     return(RedirectToAction("Details", new { CreditId = creditId }));
 }
Exemplo n.º 22
0
 public CreditController(CreditService creditService)
 {
     _creditService = creditService;
 }
Exemplo n.º 23
0
        public ActionResult Details(int creditId)
        {
            var credit = CreditService.Get(creditId);

            return(View(credit.ToCredit(SystemInformationService)));
        }
Exemplo n.º 24
0
 public CreditServiceTest()
 {
     this.creditService = new CreditService();
 }
Exemplo n.º 25
0
        public ActionResult Index()
        {
            var credits = CreditService.GetAll();

            return(View(credits.Select(e => e.ToCredit(SystemInformationService))));
        }
 public CreditsController(ClientService clientService, CreditService creditService)
 {
     _clientService = clientService;
     _creditService = creditService;
 }
Exemplo n.º 27
0
 private void CloseBankDayWork()
 {
     DepositService.CloseBankDay();
     CreditService.CloseBankDay();
     SystemInformationService.IncreaseCurrentBankDay();
 }
Exemplo n.º 28
0
        public GeneralResponse EditCreditServices(EditCreditServiceRequest request, Guid EmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                CreditService creditService = _creditServiceRepository.FindBy(request.ID);

                if (creditService != null)
                {
                    #region Validate Uncredit Service Code

                    string _errorMessag = EditValidate(request.CreditServiceCode, request.ServiceName, request.ID);

                    if (_errorMessag != "NoError")
                    {
                        response.ErrorMessages.Add(_errorMessag);
                        return(response);
                    }

                    #endregion


                    if (request.MaxDiscount > request.UnitPrice)
                    {
                        response.ErrorMessages.Add("تخفیف نمیتواند بیش از قیمت پایه باشد");
                        return(response);
                    }

                    creditService.ModifiedDate      = PersianDateTime.Now;
                    creditService.ModifiedEmployee  = _employeeRepository.FindBy(EmployeeID);
                    creditService.CreditServiceCode = request.CreditServiceCode;
                    creditService.Discontinued      = request.Discontinued;
                    creditService.ExpDays           = request.ExpDays;
                    creditService.Imposition        = request.Imposition;
                    creditService.MaxDiscount       = request.MaxDiscount;
                    if (creditService.Network.ID != request.NetworkID)
                    {
                        creditService.Network = this._networkRepository.FindBy(request.NetworkID);
                    }
                    creditService.PurchaseUnitPrice = request.PurchaseUnitPrice;
                    creditService.ResellerUnitPrice = request.ResellerUnitPrice;
                    creditService.Bonus             = request.Bonus;
                    creditService.Comission         = request.Comission;
                    if (request.ServiceName != null)
                    {
                        creditService.ServiceName = request.ServiceName;
                    }
                    creditService.UnitPrice = request.UnitPrice;
                    if (request.Note != null)
                    {
                        creditService.Note = request.Note;
                    }
                    creditService.Discontinued = request.Discontinued;

                    #region Validation

                    if (creditService.RowVersion != request.RowVersion)
                    {
                        response.ErrorMessages.Add("EditConcurrencyKey");
                        return(response);
                    }
                    else
                    {
                        creditService.RowVersion += 1;
                    }

                    if (creditService.GetBrokenRules().Count() > 0)
                    {
                        foreach (BusinessRule businessRule in creditService.GetBrokenRules())
                        {
                            response.ErrorMessages.Add(businessRule.Rule);
                        }

                        return(response);
                    }

                    #endregion

                    _creditServiceRepository.Save(creditService);
                }
                else
                {
                    response.ErrorMessages.Add("NoItemToEditKey");
                }
                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Exemplo n.º 29
0
 public static CreditServiceView ConvertToCreditServiceView(this CreditService creditService)
 {
     return(Mapper.Map <CreditService, CreditServiceView>(creditService));
 }
Exemplo n.º 30
0
        public GeneralResponse EditCreditService(EditCreditServiceRequestOld request)
        {
            GeneralResponse response      = new GeneralResponse();
            CreditService   creditService = new CreditService();

            creditService = _creditServiceRepository.FindBy(request.ID);

            if (creditService != null)
            {
                try
                {
                    creditService.ModifiedDate      = PersianDateTime.Now;
                    creditService.ModifiedEmployee  = _employeeRepository.FindBy(request.ModifiedEmployeeID);
                    creditService.CreditServiceCode = request.CreditServiceCode;
                    creditService.Discontinued      = request.Discontinued;
                    creditService.ExpDays           = request.ExpDays;
                    creditService.Imposition        = request.Imposition;
                    creditService.MaxDiscount       = request.MaxDiscount;
                    creditService.Network           = this._networkRepository.FindBy(request.NetworkID);
                    creditService.PurchaseUnitPrice = request.PurchaseUnitPrice;
                    creditService.ResellerUnitPrice = request.ResellerUnitPrice;
                    if (request.ServiceName != null)
                    {
                        creditService.ServiceName = request.ServiceName;
                    }
                    creditService.UnitPrice = request.UnitPrice;
                    if (request.Note != null)
                    {
                        creditService.Note = request.Note;
                    }
                    creditService.Discontinued = request.Discontinued;

                    if (creditService.RowVersion != request.RowVersion)
                    {
                        response.ErrorMessages.Add("EditConcurrencyKey");
                        return(response);
                    }
                    else
                    {
                        creditService.RowVersion += 1;
                    }

                    if (creditService.GetBrokenRules().Count() > 0)
                    {
                        foreach (BusinessRule businessRule in creditService.GetBrokenRules())
                        {
                            response.ErrorMessages.Add(businessRule.Rule);
                        }

                        return(response);
                    }

                    _creditServiceRepository.Save(creditService);
                    _uow.Commit();

                    ////response.success = true;
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                }
            }
            else
            {
                response.ErrorMessages.Add("NoItemToEditKey");
            }
            return(response);
        }