예제 #1
0
        private CreditViewModel GetEmptyCreditViewModel()
        {
            var viewModel = new CreditViewModel();

            return viewModel;
        }
예제 #2
0
        private CreditViewModel GetCreditViewModel(Guid creditId)
        {
            var credit = _creditService.Get(creditId);
            if (credit == null)
            {
                return null;
            }

            var viewModel = new CreditViewModel()
            {
                Id = credit.Id,
                DateStart =  credit.DateStart,
                DateEnd = credit.DateEnd,
                Percent = credit.Percent,
                PayCount = credit.PayCount,
                PayMounth = credit.PayMounth,
                Penya = credit.Penya,
                StartSum = credit.StartSum,
                Status = credit.Status,
                Number = credit.Number,
                Person = new UserInfoViewModel()
                {
                    Id = credit.Persons.Id,
                    Name = credit.Persons.Name,
                    Email = credit.Persons.Login,
                    LastName = credit.Persons.LastName,
                    SecondName = credit.Persons.SecondName
                }
            };

            decimal dept = credit.CreditHistory.Sum(creditHistoryItem => creditHistoryItem.Arrears);
            dept += credit.CreditHistory.Sum(creditHistoryItem => creditHistoryItem.Fine);
            dept = (int)Math.Ceiling(dept);

            viewModel.CurrentDept = dept;
            viewModel.AllSum = credit.CreditHistory.Sum(x => x.TotalPayment);

            return viewModel;
        }