Esempio n. 1
0
 public IActionResult OnPost()
 {
     if (ModelState.IsValid)
     {
         var customer = customerInMemory.GetCustomer(Visit.CustomerId.Value);
         Visit.Customer = customer;
         foreach (var product in Products)
         {
             if (product.Selected)
             {
                 Visit.AddProduct(product);
             }
         }
         foreach (var service in Services)
         {
             if (service.Selected)
             {
                 Visit.AddService(service);
             }
         }
         Visit = visitInMemory.AddVisit(Visit);
         return(RedirectToPage("/Visit/List"));
     }
     else
     {
         Products = productInMemory.GetProducts();
         Services = serviceInMemory.GetServices();
         return(Page());
     }
     //var customer = customerInMemory.GetCustomer(Visit.CustomerId.Value);
     //Visit.Customer = customer;
     //foreach (var product in Products)
     //{
     //    if (product.Selected)
     //    {
     //        Visit.AddProduct(product);
     //    }
     //}
     //foreach (var service in Services)
     //{
     //    if (service.Selected)
     //    {
     //        Visit.AddService(service);
     //    }
     //}
     //Visit = visitInMemory.AddVisit(Visit);
     //return RedirectToPage("/Visit/List");
 }
Esempio n. 2
0
 public IActionResult OnPost()
 {
     if (ModelState.IsValid)
     {
         var person = personInMemory.GetPerson(Visit.PersonId);
         Visit.Person        = person;
         Visit               = visitInMemory.AddVisit(Visit);
         TempData["Message"] = "Thank you for your purchase!";
         return(RedirectToPage("./List"));
     }
     CustomerNames = personInMemory.GetPeople().Select(x => new SelectListItem
     {
         Value = x.Id.ToString(),
         Text  = x.Name
     }).ToList();
     return(Page());
 }