// // GET: /Customer/Details/5 public ActionResult Details(int id ) { var customer = repository.DetailsCustomer(id); //Customer customer = db.Customers.Find(id); var customerView = new CustomerDTO { Firstname = customer.Firstname, Lastname = customer.Lastname, Phone = customer.Phone, Mail = customer.Mail, Street = customer.Street, HouseNumber= customer.HouseNumber, PostalCode= customer.PostalCode, City= customer.City, Native= customer.Native, AmountOfFreeRides = customer.AmountOfFreeRides, }; if (customerView == null) { return HttpNotFound(); } return View(customerView); }
// // GET: /Customer/ public ActionResult Index() { var viewCustomer = new CustomerDTO { CustomerList = repository.GetAllCustomer(), }; return View(viewCustomer); }
public Models.Customer CreateCustomer(CustomerDTO customerDTO) { var customer = new Customer { Firstname = customerDTO.Firstname, Lastname = customerDTO.Lastname, Phone = customerDTO.Phone, Mail = customerDTO.Mail, Street = customerDTO.Street, HouseNumber = customerDTO.HouseNumber, PostalCode = customerDTO.PostalCode, City = customerDTO.City, Native = customerDTO.Native, AmountOfFreeRides = customerDTO.AmountOfFreeRides, }; return customer; }
public ActionResult Edit(CustomerDTO customerDTO) { var customer = new Customer { CustomerId = customerDTO.CustomerId, Firstname = customerDTO.Firstname, Lastname = customerDTO.Lastname, Phone = customerDTO.Phone, Mail = customerDTO.Mail, Street = customerDTO.Street, HouseNumber = customerDTO.HouseNumber, PostalCode = customerDTO.PostalCode, City = customerDTO.City, Native = customerDTO.Native, AmountOfFreeRides = customerDTO.AmountOfFreeRides, }; if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(customerDTO); }
public ActionResult Create(CustomerDTO customerDTO) { var customer = repository.CreateCustomer(customerDTO); //repository.CreateCustomer(customerDTO); if (ModelState.IsValid) { db.Customers.Add(customer); db.SaveChanges(); } //return View(); return RedirectToAction("Index"); }