示例#1
0
        public void GetLoanTypes_EmptyLoanTypes_AreEqual()
        {
            LoanTypeService lts = new LoanTypeService();

            LoanTypes lt    = new LoanTypes();
            LoanTypes getLT = lts.GetLoanTypes();

            Assert.AreEqual(getLT.Types.Count, lt.Types.Count);
        }
示例#2
0
        public void SaveLoanTypes_EmptyLoanTypes_AreEqual()
        {
            LoanTypeService lts = new LoanTypeService();

            LoanTypes lt = new LoanTypes();

            lts.SaveLoanTypes(lt);

            Assert.AreEqual(lts.GetLoanTypes(), lt);
        }
        public async Task <bool> UpdateLoanTypes(LoanTypes loanTypes)
        {
            try
            {
                _context.LoanType.Update(loanTypes);
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#4
0
        private void LoadList()
        {
            var loanTypes = _service.GetLoanTypes();

            LoanTypes.Clear();

            if (loanTypes != null)
            {
                foreach (var loanTypeItem in loanTypes.Types)
                {
                    LoanTypes.Add(new LoanTypesListItemViewModel(loanTypeItem.Id, loanTypeItem.TypeName, _eventAggregator));
                }
            }
        }
示例#5
0
 public void SetLoanType()
 {
     logForCalculator($"SetLoanType() Currently LoanType={LoanType}");
     if (this.LoanType == LoanTypes.None)
     {
         if (PurchasePrice > HouseMin)
         {
             LoanType = LoanTypes.Home;
         }
         else
         {
             LoanType = LoanTypes.Car;
         }
     }
     logForCalculator($"SetLoanType() Now LoanType={LoanType}");
 }
        public async Task <IActionResult> UpdateLoanTypes([FromBody] LoanTypes loanTypesRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var loanTypes = await _loanTypesService.GetLoanTypeById(loanTypesRequest.Id);

                loanTypes.Type        = loanTypesRequest.Type;
                loanTypes.Description = loanTypesRequest.Description;
                var response = await _loanTypesService.UpdateLoanTypes(loanTypes);

                return(Ok(response));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
                // throw; // Add logger and exception filter to remove try catch
            }
        }
示例#7
0
 public void SaveLoanTypes(LoanTypes loanTypes)
 {
     throw new NotImplementedException();
 }
示例#8
0
        public void Fill()
        {
            // Fill database only first time - there is no need to fill it every user's request
            if (!_firstFill)
            {
                return;
            }
            _firstFill = false;

            Accounts.RemoveRange(Accounts);
            AccountTypes.RemoveRange(AccountTypes);
            Categories.RemoveRange(Categories);
            Counterparts.RemoveRange(Counterparts);
            Currencies.RemoveRange(Currencies);
            LoanTypes.RemoveRange(LoanTypes);
            Transactions.RemoveRange(Transactions);
            TransactionTypes.RemoveRange(TransactionTypes);
            Icons.RemoveRange(Icons);
            SaveChanges();

            var accountTypes = new List <AccountType>
            {
                new AccountType {
                    Title = "Наличные"
                },
                new AccountType {
                    Title = "Кредитная карта"
                },
                new AccountType {
                    Title = "Дебитовая карта"
                },
            };

            AddRange(accountTypes);

            var currencies = new List <Currency>
            {
                new Currency {
                    Title = "Рубли", Symbol = "₽"
                },
                new Currency {
                    Title = "Доллары", Symbol = "$"
                },
                new Currency {
                    Title = "Евро", Symbol = "€"
                },
                new Currency {
                    Title = "Юани", Symbol = "¥"
                },
                new Currency {
                    Title = "Гривны", Symbol = "₴"
                },
            };

            AddRange(currencies);

            var accountTitles = new List <string>
            {
                "Тинькофф рубли",
                "Сбербанк",
                "Наличные доллары",
                "Юани оставшиеся с поездки",
            };

            var accounts = Enumerable.Range(1, GetRandomValue(15)).Select(index =>
            {
                return(new Account
                {
                    AccountType = accountTypes.GetAny(),
                    Currency = currencies.GetAny(),
                    Title = accountTitles.GetAny()
                });
            });

            AddRange(accounts);

            // TODO: there are much more icons in TempData file
            var icons = TempData.Icons.Take(20).Select(icon => new Icon {
                Tag = icon
            });

            AddRange(icons);

            var categories = new List <Category>
            {
                new Category {
                    Title = "Свободные", Icon = icons.GetAny()
                },
                new Category {
                    Title = "Продукты", Icon = icons.GetAny()
                },
                new Category {
                    Title = "Здоровье", Icon = icons.GetAny()
                },
                new Category {
                    Title = "Дети", Icon = icons.GetAny()
                },
                new Category {
                    Title = "Животные", Icon = icons.GetAny()
                },
                new Category {
                    Title = "Автомобиль", Icon = icons.GetAny()
                },
            };

            AddRange(categories);

            var loanTypes = new List <LoanType>
            {
                new LoanType {
                    Title = "Мне дали/Мне вернули"
                },
                new LoanType {
                    Title = "Я дал/Я вернул"
                },
            };

            AddRange(loanTypes);

            var transactionTypes = new List <TransactionType>
            {
                new TransactionType {
                    Id = 1, Title = "Расход"
                },
                new TransactionType {
                    Id = 2, Title = "Приход"
                },
                new TransactionType {
                    Id = 3, Title = "Перевод между счетами"
                },
                new TransactionType {
                    Id = 4, Title = "Долг"
                },
            };

            AddRange(transactionTypes);

            var counterparts = new List <Counterpart>
            {
                new Counterpart {
                    Title = "Пятерочка"
                },
                new Counterpart {
                    Title = "Дядя Сережа"
                },
                new Counterpart {
                    Title = "Петька"
                },
                new Counterpart {
                    Title = "ООО Рога и копыта"
                },
                new Counterpart {
                    Title = "ИП Мясников Николай Иванович"
                },
                new Counterpart {
                    Title = "ИП Овчинников А.П."
                },
                new Counterpart {
                    Title = "Сбербанк"
                },
                new Counterpart {
                    Title = "Билайн"
                },
                new Counterpart {
                    Title = "ОАО Кольцово"
                },
                new Counterpart {
                    Title = "ПАО Энергосбыт"
                },
            };

            AddRange(counterparts);


            var transactions = Enumerable.Range(1, GetRandomValue(1000)).Select(index =>
            {
                var transaction = new Transaction
                {
                    Account         = accounts.GetAny(),
                    Amount          = GetRandomValue(10000),
                    Category        = categories.GetAny(),
                    Counterpart     = counterparts.GetAny(),
                    Date            = DateTime.Now.AddMinutes(new Random().Next(-100000, 0)),
                    TransactionType = transactionTypes.GetAny(),
                };
                if (transaction.TransactionType.Title.Equals("Долг"))
                {
                    transaction.LoanType = loanTypes.GetAny();
                }

                return(transaction);
            });

            AddRange(transactions);

            SaveChanges();
        }