Ejemplo n.º 1
0
 public ShowCustomerDetailsViewModel CreateAccountViewModelForShowDetails(ShowCustomerDetailsViewModel model, IQueryable <Accounts> customerAccounts)
 {
     model.CustomerAccounts = customerAccounts.Select(x =>
                                                      new AccountViewModel()
     {
         AccountId = x.AccountId,
         Frequency = x.Frequency,
         Created   = x.Created,
         Balance   = x.Balance
     });
     return(model);
 }
Ejemplo n.º 2
0
        public ShowCustomerDetailsViewModel CreateCustomerViewModelForShowDetails(ShowCustomerDetailsViewModel model, Customers customer)
        {
            model.CustomerId           = customer.CustomerId;
            model.Gender               = customer.Gender;
            model.Givenname            = customer.Givenname;
            model.Surname              = customer.Surname;
            model.Streetaddress        = customer.Streetaddress;
            model.City                 = customer.City;
            model.Zipcode              = customer.Zipcode;
            model.Country              = customer.Country;
            model.Birthday             = customer.Birthday;
            model.NationalId           = customer.NationalId;
            model.Telephonecountrycode = customer.Telephonecountrycode;
            model.Telephonenumber      = customer.Telephonenumber;
            model.Emailaddress         = customer.Emailaddress;

            return(model);
        }
Ejemplo n.º 3
0
        public IActionResult ShowSelectedCustomer(int id)
        {
            bool ok = true;

            if (!ModelState.IsValid || !ok)
            {
                ModelState.AddModelError(string.Empty, "Something went wrong.");

                return(View());
            }

            var customer = _customersRepository.GetOneByID(id);

            var customerAccounts = _accountServices.GetAccountsOfCustomer(customer.CustomerId);

            var model = new ShowCustomerDetailsViewModel();

            _viewmodelsServices.CreateCustomerViewModelForShowDetails(model, customer);
            _viewmodelsServices.CreateAccountViewModelForShowDetails(model, customerAccounts);
            model.TotalAmountOnAccounts = _accountServices.GetBalanceOnAllCustomerAccounts(customer.CustomerId);

            return(View(model));
        }