Exemplo n.º 1
0
        public ActionResult Create(Customer customer)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Lib.Location libStore = StoreRepo.GetAllStores().First();
                    CustomerRepo.AddCustomer(new Lib.Customer
                    {
                        FirstName = customer.FirstName,
                        LastName  = customer.LastName,
                        Birthday  = customer.Birthday,
                        StoreId   = libStore.LocationId
                    });
                    CustomerRepo.Save();



                    return(RedirectToAction(nameof(Index)));
                }
                return(View(customer));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            CustomerRepo customerRepo = new CustomerRepo();
            StoreRepo    storeRepo    = new StoreRepo();
            ProductRepo  productRepo  = new ProductRepo();

            var objModel = new Tuple <IEnumerable <SelectListItem>, IEnumerable <SelectListItem>, IEnumerable <SelectListItem> >
                               (customerRepo.GetAllCustomers(), storeRepo.GetAllStores(), productRepo.GetAllProducts());


            return(View(objModel));
        }
Exemplo n.º 3
0
        // GET: Customer/Details/5
        public ActionResult Details(int id)
        {
            Lib.Customer libCustomer = CustomerRepo.GetCustomerById(id);
            Lib.Location libStore    = StoreRepo.GetAllStores().First();
            var          webCust     = new Customer
            {
                Id        = libCustomer.Id,
                FirstName = libCustomer.FirstName,
                LastName  = libCustomer.LastName,
                Birthday  = libCustomer.Birthday,
                StoreId   = libCustomer.StoreId
            };

            CustomerViewModel cvm = new CustomerViewModel(libCustomer, libStore);

            return(View(cvm));
        }