public ActionResult Create(HotelDetail hotelDetail)
 {
     if (Session["UserRole"] != null && Session["UserRole"].ToString() == "1")
     {
         if (ModelState.IsValid)
         {
             string fileName = Path.GetFileName(hotelDetail.ImageFile.FileName);
             hotelDetail.HotelImage = "~/Image/" + fileName;
             fileName = Path.Combine(Server.MapPath("~/Image"), fileName);
             hotelDetail.ImageFile.SaveAs(fileName);
             db.HotelDetails.Add(hotelDetail);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.CategoryId = new SelectList(db.HotelCategories, "CategoryId", "CategoryName", hotelDetail.CategoryId);
         return(View(hotelDetail));
     }
     else
     {
         Response.Write("<script>alert('Session logged out. Sign in again');</script>");
         FormsAuthentication.SignOut();
         Session.Clear();
         return(RedirectToAction("SignIn", "Auth"));
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            BookingDetail bookingDetail = db.BookingDetails.Find(id);

            db.BookingDetails.Remove(bookingDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Create(BookingDetail bookingDetail)
 {
     if (Session["UserRole"] != null && Session["UserRole"].ToString() == "2")
     {
         if (ModelState.IsValid)
         {
             bookingDetail.UserId = Convert.ToInt32(Session["UserId"]);
             bookingDetail.Status = "Book";
             db.BookingDetails.Add(bookingDetail);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.UserName = new SelectList(db.UserDetails.Where(u => u.UserTypeId == 2), "FirstName", "FirstName");
         ViewBag.HotelId  = new SelectList(db.HotelDetails, "HotelId", "HotelName", bookingDetail.HotelId);
         return(View(bookingDetail));
     }
     else
     {
         Response.Write("<script>alert('Session logged out. Sign in again');</script>");
         FormsAuthentication.SignOut();
         Session.Clear();
         return(RedirectToAction("SignIn", "Auth"));
     }
 }
        public ActionResult SignUp(UserDetail userDetail)
        {
            if (ModelState.IsValid)
            {
                userDetail.UserTypeId = 2;

                using (var context = new HotelBookingSystemEntities())
                {
                    context.UserDetails.Add(userDetail);
                    context.SaveChanges();
                    return(RedirectToAction("SignIn"));
                }
            }
            return(View());
        }