コード例 #1
0
 public ActionResult Add([Bind(Include = "Name, BirthDate")] AddCustomerBm bind)
 {
     if (this.ModelState.IsValid)
     {
         this.service.AddCustomerBm(bind);
         return(this.RedirectToAction("All", new { order = "Ascending" }));
     }
     return(this.View());
 }
コード例 #2
0
        public void AddCustomerBm(AddCustomerBm bind)
        {
            Customer customer = Mapper.Instance.Map <AddCustomerBm, Customer>(bind);

            if (DateTime.Now.Year - bind.BirthDate.Year > 21)
            {
                customer.IsYoungDriver = true;
            }
            this.Context.Customers.Add(customer);
            this.Context.SaveChanges();
        }
コード例 #3
0
        public void AddCustomer(AddCustomerBm customerBm)
        {
            Customer customer = Mapper.Map <AddCustomerBm, Customer>(customerBm);

            if (DateTime.Now.Year - customerBm.BirthDate.Year < 21)
            {
                customer.IsYoungDriver = true;
            }
            this.Context.Customers.Add(customer);
            this.Context.SaveChanges();
        }
コード例 #4
0
        public void AddCustomerBm(AddCustomerBm model)
        {
            var customer = Mapper.Instance.Map <AddCustomerBm, Customer>(model);

            customer.IsYoungDriver = false;


            if (DateTime.Now.Year - model.BirthDate.Year < 21)
            {
                customer.IsYoungDriver = true;
            }

            this.context.Customers.Add(customer);
            this.context.SaveChanges();
        }