Beispiel #1
0
 private async void PreviusButton_Clicked(object sender, System.EventArgs e)
 {
     if (_viewModel.Position > 0)
     {
         if (_viewModel.IsValid(_viewModel.Pages[_viewModel.Position]))
         {
             _viewModel.Position = Carousel.Position - 1;
         }
     }
 }
Beispiel #2
0
        //private IBankAppDataContext _context { get; set; }

        //public CreateCustomer(IBankAppDataContext context)
        //{
        //    _context = context;
        //}

        public int Add(IBankAppDataContext _context, CustomerViewModel model)
        {
            Customer customer = new Customer();

            if (model.IsValid())
            {
                customer.Birthday             = model.Birthday;
                customer.City                 = model.City;
                customer.Country              = model.Country;
                customer.CountryCode          = model.CountryCode;
                customer.Emailaddress         = model.Emailaddress;
                customer.Gender               = model.Gender;
                customer.Givenname            = model.Givenname;
                customer.Surname              = model.Surname;
                customer.Telephonecountrycode = model.Telephonecountrycode;
                customer.Telephonenumber      = model.Telephonenumber;
                customer.Zipcode              = model.Zipcode;
                customer.NationalId           = model.NationalId;
                customer.Streetaddress        = model.Streetaddress;

                _context.Customers.Add(customer);
                _context.Save();

                Account account = new Account()
                {
                    Balance   = 0,
                    Created   = DateTime.Now,
                    Frequency = "Monthly"
                };
                _context.Accounts.Add(account);
                _context.Save();

                Disposition disposition = new Disposition()
                {
                    Account  = account,
                    Customer = customer,
                    Type     = "Owner"
                };
                _context.Dispositions.Add(disposition);
                _context.Save();
            }
            return(customer.CustomerId);
        }
 public CustomerViewModel Edit(CustomerViewModel model)
 {
     if (model.IsValid() && model.CustomerId != 0)
     {
         Customer customer = _context.Customers.Where(c => c.CustomerId == model.CustomerId).SingleOrDefault();
         customer.Birthday             = model.Birthday;
         customer.City                 = model.City;
         customer.Country              = model.Country;
         customer.CountryCode          = model.CountryCode;
         customer.Emailaddress         = model.Emailaddress;
         customer.Gender               = model.Gender;
         customer.Givenname            = model.Givenname;
         customer.Surname              = model.Surname;
         customer.Telephonecountrycode = model.Telephonecountrycode;
         customer.Telephonenumber      = model.Telephonenumber;
         customer.Zipcode              = model.Zipcode;
         customer.NationalId           = model.NationalId;
         customer.Streetaddress        = model.Streetaddress;
         _context.Customers.Update(customer);
         _context.Save();//new System.Threading.CancellationToken()); // Hope this works
         return(model);
     }
     return(model);
 }