예제 #1
0
 public virtual ActionResult Excluir(int id, object diff)
 {
     TReservation.Delete(x => x.Id == id);
     TMovie.Delete(x => x.Id == id);
     TIten.Delete(id);
     return(RedirectToAction("Index"));
 }
예제 #2
0
        public virtual ActionResult Reservar()
        {
            var reserva = new TReservation();

            ViewBag.Movie = TMovie.ListAll().ToSelectList(x => x.Id, x => x.Name);
            return(View(reserva));
        }
예제 #3
0
        public virtual ActionResult ListForSubGrid(string id)
        {
            IList <TReservationDetail> details = new List <TReservationDetail>();

            TReservation reservation = _reservationRepository.Get(id);

            if (reservation != null)
            {
                details = reservation.ReservationDetails;
            }

            var jsonData = new
            {
                rows = (
                    from detail in details
                    select new
                {
                    i = detail.Id.ToString(),
                    cell = new string[] {
                        detail.ReservationDetailName,
                        detail.PacketId != null ?  detail.PacketId.PacketName : null,
                        detail.EmployeeId != null? detail.EmployeeId.PersonId.PersonName : null
                    }
                }).ToArray()
            };


            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        //[AcceptVerbs(HttpVerbs.Post)]
        public virtual ActionResult UpdateStatus(string reservationId, string status)
        {
            _reservationRepository.DbContext.BeginTransaction();
            TReservation reservation = _reservationRepository.Get(reservationId);

            if (reservation != null)
            {
                reservation.ReservationStatus = status;
                reservation.DataStatus        = EnumDataStatus.Updated.ToString();
                reservation.ModifiedBy        = User.Identity.Name;
                reservation.ModifiedDate      = DateTime.Now;
                _reservationRepository.Update(reservation);
            }

            try
            {
                _reservationRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _reservationRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("Data reservasi berhasil diupdate"));
        }
예제 #5
0
        public virtual ActionResult Editar(int id)
        {
            var itens = new TIten();

            ViewBag.Reservation = TReservation.ListAll().ToSelectList(x => x.Id, x => x.Id);
            ViewBag.Movie       = TMovie.ListAll().ToSelectList(x => x.Id, x => x.Id);
            return(View());
        }
예제 #6
0
        public virtual ActionResult Cadastrar()
        {
            var reserva = new TReservation();

            ViewBag.Client = TClient.ListAll().ToSelectList(x => x.Id, x => x.Name);
            ViewBag.Iten   = TMovie.ListAll().ToSelectList(x => x.Id, x => x.Name);
            return(View(reserva));
        }
예제 #7
0
        public virtual ActionResult Editar(int id)
        {
            var reserva = TReservation.Load(id);

            ViewBag.Client = TClient.ListAll().ToSelectList(x => x.Id, x => x.Name);
            ViewBag.Iten   = TMovie.ListAll().ToSelectList(x => x.Id, x => x.Name);
            ViewBag.Sale   = TSale.ListAll().ToSelectList(x => x.Id, x => x.EnumStatusSale);
            return(View(reserva));
        }
예제 #8
0
        //view Survey page
        public IActionResult Survey(int id)
        {
            var tRes = new TReservation {
                ResId = id, ResStatus = 1
            };

            _context.TReservations.Attach(tRes);
            _context.Entry(tRes).Property(x => x.ResStatus).IsModified = true;
            _context.SaveChanges();

            ViewBag.ResId = id;
            return(View());
        }
        public static ReservationFormViewModel Create()
        {
            ReservationFormViewModel viewModel   = new ReservationFormViewModel();
            TReservation             reservation = new TReservation();

            reservation.ReservationDate           = DateTime.Today;
            reservation.ReservationAppoinmentTime = DateTime.Now;
            reservation.ReservationIsMember       = false;
            reservation.ReservationNoOfPeople     = 1;

            viewModel.Reservation = reservation;
            return(viewModel);
        }
예제 #10
0
 public virtual ActionResult Reservar(TReservation model)
 {
     try
     {
         model.Save();
         TIten.SaveMovies(model);
         TempData["Alerta"] = new Alert("success", "Reserva realizada com sucesso");
         return(RedirectToAction("cliente_filmes"));
     }
     catch (SimpleValidationException ex)
     {
         return(HandleViewException(model, ex));
     }
 }
예제 #11
0
 public virtual ActionResult Editar(TReservation model)
 {
     try
     {
         model.Update();
         TIten.SaveIten(model);
         TempData["Alert"] = new Alert("success", "Sua reserva foi editada com sucesso");
         return(RedirectToAction("Index"));
     }
     catch (SimpleValidationException ex)
     {
         return(HandleViewException(model, ex));
     }
 }
예제 #12
0
 public void SaveIten(TReservation model)
 {
     TIten.Delete(x => x.Movie.Id == model.Id);
     if (model.Iten != null)
     {
         for (int i = 0; i < model.itensdareserva.Length; i++)
         {
             new TIten()
             {
                 Reservation = model,
                 Movie       = TMovie.Load(model.itensdareserva[i])
             }.Save();
         }
     }
 }
예제 #13
0
 public virtual ActionResult Editar(TIten model)
 {
     try
     {
         TempData["Alert"] = new Alert("success", "Seu item foi editado com sucesso");
         model.Save();
         return(RedirectToAction("Index"));
     }
     catch (SimpleValidationException ex)
     {
         ViewBag.Reservation = TReservation.ListAll().ToSelectList(x => x.Id, x => x.Id);
         ViewBag.Movie       = TMovie.ListAll().ToSelectList(x => x.Id, x => x.Id);
         return(HandleViewException(model, ex));
     }
 }
예제 #14
0
        public void SaveMovies(TReservation model)
        {
            TIten.Delete(x => x.Reservation.Id == model.Id);

            if (model.Movies != null)
            {
                for (int i = 0; i < model.Movies.Length; i++)
                {
                    var movie = TMovie.Load(model.Movies[i]);
                    new TIten()
                    {
                        Reservation = model,
                        Movie       = movie,
                        Value       = movie.Value.Value,
                        Quantity    = model.Quantities[i]
                    }.Save();
                }
            }
        }
예제 #15
0
        //Confirm reservation
        public async System.Threading.Tasks.Task <IActionResult> MakeReservation()
        {
            if (HttpContext.Session.GetInt32("pending") != 1)
            {
                return(RedirectToAction(nameof(Index)));
            }

            var dateFrom = DateTime.Parse(HttpContext.Session.GetString("resFrom"));
            var dateTo   = DateTime.Parse(HttpContext.Session.GetString("resTo"));
            var uid      = HttpContext.Session.GetInt32("UID");

            var tRes = new TReservation {
                ResFrom = dateFrom, ResTo = dateTo, UserId = uid
            };

            _context.Add(tRes);
            if (await _context.SaveChangesAsync() > 0)
            {
                int resId    = _context.TReservations.Max(x => x.ResId);
                var listRoom = JsonConvert.DeserializeObject <List <TRoom> >(HttpContext.Session.GetString("rooms"));
                var resRoom  = new List <TReservationRoom>();

                foreach (var item in listRoom)
                {
                    var temp = new TReservationRoom {
                        ResId = resId, RoomId = decimal.ToInt16(item.RoomId)
                    };
                    resRoom.Add(temp);
                }

                _context.TReservationRooms.AddRange(resRoom);
                if (await _context.SaveChangesAsync() > 0)
                {
                    HttpContext.Session.SetInt32("pending", 0);
                    HttpContext.Session.SetString("rooms", "");
                    return(RedirectToAction(nameof(Complete)));
                }
            }

            TempData["Error"] = "Unable to create the reservation. Please try again";
            return(RedirectToAction(nameof(Reservation)));
        }
예제 #16
0
        public virtual ActionResult Delete(TReservation viewModel, FormCollection formCollection)
        {
            _reservationRepository.DbContext.BeginTransaction();
            TReservation reservation = _reservationRepository.Get(viewModel.Id);

            if (reservation != null)
            {
                _reservationRepository.Delete(reservation);
            }

            try
            {
                _reservationRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _reservationRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("Data reservasi berhasil dihapus"));
        }
예제 #17
0
        public virtual ActionResult Index()
        {
            var reserva = TReservation.ListAll().ToList();

            return(View(reserva));
        }
예제 #18
0
        public virtual ActionResult AddNew(TReservation reservation, FormCollection formCollection)
        {
            string Message = "Data reservasi berhasil disimpan";
            bool   Success = true;

            _reservationRepository.DbContext.BeginTransaction();
            reservation.SetAssignedIdTo(Guid.NewGuid().ToString());
            if (!string.IsNullOrEmpty(formCollection["CustomerId"]))
            {
                reservation.CustomerId          = _mCustomerRepository.Get(formCollection["CustomerId"]);
                reservation.ReservationIsMember = true;
            }
            else
            {
                reservation.ReservationIsMember = false;
            }
            reservation.ReservationStatus = EnumReservationStatus.Baru.ToString();
            reservation.DataStatus        = EnumDataStatus.New.ToString();
            reservation.CreatedBy         = User.Identity.Name;
            reservation.CreatedDate       = DateTime.Now;
            _reservationRepository.Save(reservation);

            TReservationDetail detail;

            //loop ReservationNoOfPeople
            MPacket   packet;
            MEmployee employee;

            for (int i = 0; i < reservation.ReservationNoOfPeople; i++)
            {
                detail = new TReservationDetail(reservation);
                detail.SetAssignedIdTo(Guid.NewGuid().ToString());
                detail.ReservationDetailName = formCollection["txtDetailName_" + i.ToString()];
                if (!string.IsNullOrEmpty(formCollection["txtPacketId_" + i.ToString()]))
                {
                    detail.PacketId = _mPacketRepository.Get(formCollection["txtPacketId_" + i.ToString()]);
                }
                if (!string.IsNullOrEmpty(formCollection["txtEmployeeId_" + i.ToString()]))
                {
                    detail.EmployeeId = _mEmployeeRepository.Get(formCollection["txtEmployeeId_" + i.ToString()]);
                }
                detail.DataStatus  = EnumDataStatus.New.ToString();
                detail.CreatedBy   = User.Identity.Name;
                detail.CreatedDate = DateTime.Now;
                _reservationDetailRepository.Save(detail);
            }

            try
            {
                _reservationRepository.DbContext.CommitTransaction();
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Success;
            }
            catch (Exception ex)
            {
                Success = false;
                Message = ex.Message;
                _reservationRepository.DbContext.RollbackTransaction();
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Failed;
            }

            var e = new
            {
                Success,
                Message
            };

            return(Json(e, JsonRequestBehavior.AllowGet));
        }
예제 #19
0
        public virtual ActionResult Excluir(int id)
        {
            var reserva = TReservation.Load(id);

            return(PartialView("_excluir", reserva));
        }
예제 #20
0
        public virtual ActionResult ListarCliente(int id)
        {
            var reservation = TReservation.Load(id);

            return(PartialView("_listar-reserva", reservation));
        }