Esempio n. 1
0
        public ViewResult CustomerAdd()
        {
            CustomerDataView customerDV = new CustomerDataView()
            {
                Sexes = FakeDB.GetSelectListItemSex()
            };

            return(View(customerDV));
        }
Esempio n. 2
0
        public ViewResult CustomerEdit(int customerId)
        {
            Customer         customer   = FakeDB.GetCustomers().First(c => c.Id == customerId);
            CustomerDataView customerDV = new CustomerDataView()
            {
                Sexes    = FakeDB.GetSelectListItemSex(),
                Customer = customer,
                SexId    = customer.Sex.Id
            };

            return(View(customerDV));
        }
Esempio n. 3
0
        public ActionResult AddCustomer(CustomerDataView customerDV)
        {
            if (!ModelState.IsValid)
            {
                return(View("CustomerAdd",

                            new CustomerDataView()
                {
                    Sexes = FakeDB.GetSelectListItemSex(),
                    Customer = customerDV.Customer,
                    SexId = customerDV.SexId
                }));
            }

            FakeDB.InsertCustomer(customerDV.Customer);
            return(Redirect("/Customers"));
        }