public ActionResult Create(Movie movie) { if (ModelState.IsValid) { db.Movies.Add(movie); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(movie)); }
public ActionResult Create(CreateCustomerViewModel customerViewModel) { if (ModelState.IsValid) { db.Customers.Add(customerViewModel.Customer); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.membershipTypeId = new SelectList(db.MembershipTypes, "ID", "Name", customerViewModel.Customer.membershipTypeId); return(View("Create", customerViewModel)); }
public CustomerDto createCustomer(CustomerDto customerDto) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var customer = Mapper.Map <CustomerDto, Customer>(customerDto); db.Customers.Add(customer); db.SaveChanges(); customerDto.custID = customer.custID; return(customerDto); }
public MoviesDto createMovie(MoviesDto moviesDto) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var movie = Mapper.Map <MoviesDto, Movie>(moviesDto); if (movie == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } moviesDto.movieID = movie.movieID; db.Movies.Add(movie); db.SaveChanges(); return(moviesDto); }