public async Task <ActionResult> Post(CreateCinemaRequest model) { Guid cinemaId = Guid.NewGuid(); await _cinemaService.Add(cinemaId, model); return(CreatedAtRoute(nameof(GetCinemaById), new { id = cinemaId }, cinemaId)); }
public ActionResult Create(CinemaViewModel cinemaViewModel) { if (ModelState.IsValid) { Cinema cinema = new Cinema(); cinemaViewModel.CreatedDate = DateTime.Now; cinema.UpdateCinema(cinemaViewModel); if (cinema != null) { _cinemaService.Add(cinema); _cinemaService.SaveChanges(); //Redirect To Index Action //SetAlert("Thêm rạp chiếu phim thành công!", CommonConstrants.SUCCESS_ALERT); return(RedirectToAction("Index")); } } //Action/Controller ViewBag.CinemaStatus = new SelectList(_statusService.GetAll(), "StatusID", "StatusName"); //ViewBag.StaffId = new SelectList(_staffService.GetAll(), "StaffID", "StaffCode"); return(View(cinemaViewModel)); }
public ActionResult Create([Bind(Include = "Id,Image,Name,Address,PhoneNumber")] CinemaViewModel cinemaViewModel) { if (!ModelState.IsValid) { return(View(cinemaViewModel)); } string extension = Path.GetExtension((cinemaViewModel.Image.FileName)); if (extension == null) { return(RedirectToAction("Index")); } string virtualPath = FormVirtualPath(extension); string physicalPath = HttpContext.Server.MapPath(virtualPath); cinemaViewModel.ImagePath = virtualPath; CinemaDomainModel cinemaDomainModel = Mapper.Map <CinemaViewModel, CinemaDomainModel>(cinemaViewModel); _cinemaService.Add(cinemaDomainModel); cinemaViewModel.Image.SaveAs(physicalPath); return(RedirectToAction("Index")); }