public ActionResult Reservate(ReservationItemViewModel reservationItemViewModel)
 {
     if (ModelState.IsValid)
     {
         MrsContext      mrs = new MrsContext();
         SeatReservation sr  = new SeatReservation();
         sr.UserId      = int.Parse(HttpContext.Session.GetString("Id"));
         sr.IsReserved  = true;
         sr.IsPaid      = false;
         sr.SeatId      = reservationItemViewModel.SeatId;
         sr.IsActive    = true;
         sr.ScreeningId = reservationItemViewModel.ScreeningId;
         mrs.SeatReservations.Add(sr);
         mrs.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult Register(User user)
 {
     if (ModelState.IsValid)
     {
         user.AccountId = 1;
         using (MrsContext mrs = new MrsContext())
         {
             mrs.Users.Add(user);
             mrs.SaveChanges();
         }
         ModelState.Clear();
         //ViewBag.Message = user.FirstName + " " + user.LastName + " successfully registered.";
         TempData["Id"]           = user.Id.ToString();
         TempData["EmailAddress"] = user.EmailAddress.ToString();
         return(RedirectToAction("LoggedIn"));
     }
     return(View());
 }
        public ActionResult Edit(User user)
        {
            if (ModelState.IsValid)
            {
                using (MrsContext mrs = new MrsContext())
                {
                    int idUser = int.Parse(HttpContext.Session.GetString("Id"));
                    user.Id = idUser;
                    mrs.Entry(user).State = Microsoft.EntityFrameworkCore.EntityState.Modified;

                    user.AccountId = 1;

                    mrs.SaveChanges();
                    return(RedirectToAction("Profil"));
                }
            }
            return(View(user));
        }
Beispiel #4
0
        public async Task <IActionResult> Reserved(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var propAd = await _context.PropAds
                         .Include(p => p.ThematicProp)
                         .Include(p => p.User)
                         .SingleOrDefaultAsync(m => m.Id == id);

            if (propAd.UserReservedId == null)
            {
                propAd.UserReservedId = Convert.ToInt32(HttpContext.Session.GetString("Id"));
                _context.SaveChanges();
                return(View(propAd));
            }
            return(NotFound());
        }
        public async Task <ActionResult> DeleteConfirmed(long id)
        {
            MrsContext mrs = new MrsContext();

            var sr = await mrs.SeatReservations.SingleOrDefaultAsync(m => m.Id == id);

            sr.Screening = mrs.Screenings.Single(s => s.Id == sr.ScreeningId);
            DateTime dateToday  = DateTime.Now;
            DateTime srdatetime = sr.Screening.ScreenStartDateTime;

            TimeSpan difference = dateToday.Subtract(srdatetime);

            double totalMinutes = difference.TotalMinutes;

            if (Math.Abs(totalMinutes) > 30)
            {
                mrs.SeatReservations.Remove(sr);
                mrs.SaveChanges();
                return(RedirectToAction("MojeRezervacije"));
            }
            //else { ViewBag.Message("Ne mozete otkazati za manje od 30 minuta pre projekcije!"); }
            return(RedirectToAction("MojeRezervacije"));
        }