Ejemplo n.º 1
0
        public void GetReservedSeatsForSeance(long id, bool isInit)
        {
            SeanceDomainModel currentSeance =
                _seanceService.ReadById(id);

            if (currentSeance == null)
            {
                return;
            }
            _reservedSeatService.ExemptExpiredSeats(id);

            var reservedSeats = (from seat in currentSeance.ReservedSeats
                                 select new
            {
                seat.Id,
                seat.RowNumber,
                seat.ColumnNumber,
                seat.ReservationTime
            }).ToList();
            string jsonData = JsonConvert.SerializeObject(reservedSeats);

            if (isInit)
            {
                Clients.All.notify(jsonData);
            }
            else
            {
                Clients.Others.notify(jsonData);
            }
        }
Ejemplo n.º 2
0
        public void Delete(SeanceDomainModel entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            Seance seance = Mapper.Map <SeanceDomainModel, Seance>(entity);

            Uow.GetRepository <Seance>().Delete(seance);
            Uow.Save();
        }
Ejemplo n.º 3
0
        public SeanceDomainModel ReadById(object id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            Seance            seance       = Uow.GetRepository <Seance>().ReadById(id);
            SeanceDomainModel seanceDomain = Mapper.Map <Seance, SeanceDomainModel>(seance);

            return(seanceDomain);
        }
Ejemplo n.º 4
0
        public ActionResult Details(long?seanceId, bool isCommon)
        {
            if (seanceId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            SeanceDomainModel seanceDomianModel = _seanceService.ReadById(seanceId);
            SeanceViewModel   seanceViewModel   = Mapper.Map <SeanceDomainModel, SeanceViewModel>(seanceDomianModel);

            if (seanceViewModel == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(isCommon ? "_Details" : "_DetailsPartial", seanceViewModel));
        }
Ejemplo n.º 5
0
        public ActionResult Create(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SeanceDomainModel currentSeance = _seanceService.ReadById(id);

            if (currentSeance == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            ViewBag.SeanceId       = id;
            ViewBag.Hall           = currentSeance.Hall;
            ViewBag.PaymentMethods = _paymentMethodService.GetSelectListItems();
            return(View());
        }
Ejemplo n.º 6
0
        public ActionResult Edit(SeanceViewModel seanceViewModel)
        {
            if (seanceViewModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (!ModelState.IsValid)
            {
                return(PartialView("_EditPartial", seanceViewModel));
            }

            SeanceDomainModel seanceDomainModel = Mapper.Map <SeanceViewModel, SeanceDomainModel>(seanceViewModel);

            _seanceService.Update(seanceDomainModel);

            var url = Url.Action("List", "Seance", routeValues: new { filmId = seanceViewModel.FilmId });

            return(Json(new { success = true, url = url, replaceTarget = "#SeanceList" }));
        }
Ejemplo n.º 7
0
        public ActionResult Edit(long?seanceId)
        {
            if (seanceId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            SeanceDomainModel seanceDomianModel = _seanceService.ReadById(seanceId);
            SeanceViewModel   seanceViewModel   = Mapper.Map <SeanceDomainModel, SeanceViewModel>(seanceDomianModel);

            if (seanceViewModel == null)
            {
                return(HttpNotFound());
            }

            IEnumerable <SelectListItem> hallsCinemas = GetHallsCinemas();

            ViewBag.HallsCinemas = hallsCinemas;

            return(PartialView("_EditPartial", seanceViewModel));
        }
Ejemplo n.º 8
0
        public ActionResult ToogleReservationStatus([FromJson] SeatViewModel seatViewModel, long seanceId)
        {
            SeanceDomainModel currentSeance = _seanceService.ReadById(seanceId);
            string            currentUserId = User.Identity.GetUserId();

            if (currentSeance == null || seatViewModel == null)
            {
                HttpNotFound();
            }
            else
            {
                var reservedSeat = (from seat in currentSeance.ReservedSeats
                                    where seat.RowNumber == seatViewModel.RowNumber &&
                                    seat.ColumnNumber == seatViewModel.ColumnNumber
                                    select seat).SingleOrDefault();
                if (reservedSeat == null)
                {
                    ReservedSeatDomainModel currentReservedSeat = new ReservedSeatDomainModel
                    {
                        RowNumber         = seatViewModel.RowNumber,
                        ColumnNumber      = seatViewModel.ColumnNumber,
                        ReservationTime   = DateTime.Now,
                        SeanceId          = seanceId,
                        ApplicationUserId = currentUserId
                    };
                    _reservedSeatService.Add(currentReservedSeat);
                }
                else
                {
                    if (reservedSeat.ApplicationUserId != currentUserId)
                    {
                        return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
                    }
                    _reservedSeatService.Delete(reservedSeat);
                }
            }
            return(new HttpStatusCodeResult(HttpStatusCode.OK));;
        }
Ejemplo n.º 9
0
        public string GetSeanceSeats(long seanceId)
        {
            SeanceDomainModel currentSeance = _seanceService.ReadById(seanceId);

            if (currentSeance == null)
            {
                HttpNotFound();
            }
            else
            {
                var seanceHall = currentSeance.Hall;
                if (seanceHall == null)
                {
                    HttpNotFound();
                }
                else
                {
                    string jsonData = JsonConvert.SerializeObject(seanceHall.Seats);
                    return(jsonData);
                }
            }
            return(null);
        }
Ejemplo n.º 10
0
        public ActionResult Create(CreateSeanceViewModel createSeanceViewModel)
        {
            if (createSeanceViewModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (!ModelState.IsValid)
            {
                ViewBag.HallsCinemas = GetHallsCinemas();
                return(PartialView("_CreatePartial", createSeanceViewModel));
            }

            if (createSeanceViewModel.IsMultipleDateSelect)
            {
                var startDate = DateTime.ParseExact(createSeanceViewModel.Date, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                var endDate   = DateTime.ParseExact(createSeanceViewModel.EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                for (var date = startDate; date <= endDate; date = date.AddDays(1.0))
                {
                    SeanceViewModel   baseSeanceViewModel  = createSeanceViewModel;
                    SeanceDomainModel newSeanceDomainModel = Mapper.Map <SeanceViewModel, SeanceDomainModel>(baseSeanceViewModel);
                    newSeanceDomainModel.Date = date;
                    _seanceService.Add(newSeanceDomainModel);
                }
            }
            else
            {
                SeanceViewModel   seanceViewModel   = createSeanceViewModel;
                SeanceDomainModel seanceDomainModel = Mapper.Map <SeanceViewModel, SeanceDomainModel>(seanceViewModel);
                _seanceService.Add(seanceDomainModel);
            }

            var url = Url.Action("List", "Seance", routeValues: new { filmId = createSeanceViewModel.FilmId });

            return(Json(new { success = true, url = url, replaceTarget = "#SeanceList" }));
        }