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()); }
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(); }
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(); }
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(); }