public virtual ActionResult Create([Bind(Include = "Id,Name,Email,Address")] CustomerViewModel customer) { if (ModelState.IsValid) { _db.Customers.Add(customer.ToCustomer()); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public virtual ActionResult Create([Bind(Include = "Id,Name,Color,Price,DateAdded,CustomerId")] ProductViewModel product) { if (ModelState.IsValid) { _db.Products.Add(product.ToProduct()); _db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerId = new SelectList(_db.Customers, "Id", "Name", product.CustomerId); return(View(product)); }
public virtual ActionResult Create(TicketViewModel ticket) { if (ModelState.IsValid) { ticket.OwnerId = User.Identity.GetUserId(); _db.Tickets.Add(ticket.ToTicket()); _db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(_db.Products, "Id", "Name"); return(View(ticket)); }