public void AddCustomer(AddCustomerBindingModel bindingModel)
        {
            Customer customerEntity = Mapper.Map <Customer>(bindingModel);

            this.DbContext.Customers.Add(customerEntity);
            this.DbContext.SaveChanges();
        }
Beispiel #2
0
        public void AddCustomer(AddCustomerBindingModel addCustomerBindingModel)
        {
            Customer customer = Mapper.Map <AddCustomerBindingModel, Customer>(addCustomerBindingModel);

            customer.IsYoungDriver = DateTime.Now.Year - customer.BirthDate.Year < 21;
            this.Context.Customers.Add(customer);
            this.Context.SaveChanges();
        }
Beispiel #3
0
        public ActionResult Add([Bind(Include = "Name,Birthdate")] AddCustomerBindingModel bindingModel)
        {
            if (ModelState.IsValid)
            {
                this.service.AddCustomer(bindingModel);
            }

            return(RedirectToAction("All", new { criteria = "descending" }));
        }
 public ActionResult Add([Bind(Include = "Name,BirthDate")] AddCustomerBindingModel AddCustomerBindingModel)
 {
     this.service.AddCustomer(AddCustomerBindingModel);
     return(RedirectToAction("Index", "Customers/all/ascending"));
 }