예제 #1
0
        public async Task <ActionResult> Post(CreateCinemaRequest model)
        {
            Guid cinemaId = Guid.NewGuid();
            await _cinemaService.Add(cinemaId, model);

            return(CreatedAtRoute(nameof(GetCinemaById), new { id = cinemaId }, cinemaId));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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"));
        }