예제 #1
0
        public IHttpActionResult PutGuest(int id, Guest guest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != guest.Id)
            {
                return(BadRequest());
            }

            db.Entry(guest).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GuestExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult SaveOrder()
        {
            try
            {
                Bill  bill    = new Bill();
                Order order   = new Order();
                int   RID     = ((int)Session["RESEVATION"]);
                var   details = ((List <OrderItemViewModel>)Session["FoodItems"]);
                foreach (var item in details)
                {
                    order.Item_Id            = item.Item.Id;
                    order.Item_Quantity      = item.Qty;
                    order.Item_Portion_Price = item.Item.Portion_Price;
                    order.Total_Item_Price   = item.SubTotal;
                    order.Reservation_Id     = RID;
                    db.Orders.Add(order);
                    db.SaveChanges();

                    var billId = db.Bills.Where(r => r.Reservation_ID == RID).SingleOrDefault();

                    billId.Total_Charge = billId.Total_Charge + item.SubTotal;
                    db.SaveChanges();

                    Session["FoodItems"] = null;
                    Session["Total"]     = 0;
                }
                return(RedirectToAction("MyAcnt", "Home", new { guest = ((Guest_Details)Session["logindetails"]).Guest_Id }));
            }
            catch (Exception ex)
            {
                ViewBag.error = "Error On Order";
                return(View());
            }
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "Id,Latitude,Longitutde,HotelAddress,HotelDescription,HotelRating,HotelName,HotelCity")] Hotel hotel)
        {
            if (ModelState.IsValid)
            {
                db.Hotel.Add(hotel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hotel));
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "Id,RoomType,RoomDescription,TotalRoom,RoomPrice,HotelId")] Room room)
        {
            if (ModelState.IsValid)
            {
                db.Room.Add(room);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.HotelId = new SelectList(db.Hotel, "Id", "HotelName", room.HotelId);
            return(View(room));
        }
        public ActionResult Create([Bind(Include = "Id,RoomId,Date,PriceChange,AvaibleRoom")] RoomStates roomStates)
        {
            if (ModelState.IsValid)
            {
                db.RoomStates.Add(roomStates);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RoomId = new SelectList(db.Room, "Id", "RoomType", roomStates.RoomId);
            return(View(roomStates));
        }
예제 #6
0
        public ActionResult Create([Bind(Include = "Id,CheckinDate,CheckoutDate,ASPUserId,Rating,Comment,RoomId,Price,RoomNumber")] Booking booking)
        {
            if (ModelState.IsValid)
            {
                db.Booking.Add(booking);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RoomId = new SelectList(db.Room, "Id", "RoomType", booking.RoomId);
            return(View(booking));
        }
예제 #7
0
 public void AddClient(clients client)
 {
     using (HotelModel context = new HotelModel())
     {
         if (client != null)
         {
             context.clients.Add(client);
             context.SaveChanges();
         }
     }
 }
예제 #8
0
 public void RemoveClient(int id)
 {
     using (HotelModel context = new HotelModel())
     {
         clients clientToRemove = context.clients.Find(id);
         if (clientToRemove != null)
         {
             context.clients.Remove(clientToRemove);
             context.SaveChanges();
         }
     }
 }
예제 #9
0
        public ActionResult Create([Bind(Include = "Id,HotelId,ImageName,ImagePath")] Image image, HttpPostedFileBase postedFile)
        {
            ModelState.Clear();
            var myUniqueFileName = string.Format(@"{0}", Guid.NewGuid());

            image.ImagePath = myUniqueFileName;
            TryValidateModel(image);

            if (ModelState.IsValid)
            {
                string serverPath    = Server.MapPath("~/Uploads/");
                string fileExtension = Path.GetExtension(postedFile.FileName);
                string filePath      = image.ImagePath + fileExtension;
                image.ImagePath = filePath;
                postedFile.SaveAs(serverPath + image.ImagePath);
                db.Image.Add(image);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.HotelId = new SelectList(db.Hotel, "Id", "HotelAddress", image.HotelId);
            return(View(image));
        }
예제 #10
0
 public void UpdateClient(clients client)
 {
     using (HotelModel context = new HotelModel())
     {
         clients clientToUpdate = context.clients.Find(client.IdentifiantCli);
         if (clientToUpdate != null)
         {
             clientToUpdate.Nom       = client.Nom;
             clientToUpdate.Prenom    = client.Prenom;
             clientToUpdate.Telephone = client.Telephone;
             clientToUpdate.Email     = client.Email;
             context.SaveChanges();
         }
     }
 }
예제 #11
0
        public ActionResult Register(DTOGuestDetails details)
        {
            var emails = db.Guest_Details.Where(q => q.Guest_Email == details.Guest_Email).ToList();

            if (emails.Count == 0)
            {
                var originalPassword = details.Password;

                MD5    md5           = new MD5CryptoServiceProvider();
                Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
                Byte[] encodedBytes  = md5.ComputeHash(originalBytes);

                string hashPassword = BitConverter.ToString(encodedBytes);
                if (ModelState.IsValid)
                {
                    Guest_Details gd = new Guest_Details();


                    gd.Guest_Title      = details.Guest_Title;
                    gd.Guest_First_Name = details.Guest_First_Name;
                    gd.Guest_Last_Name  = details.Guest_Last_Name;
                    gd.Guest_Address    = details.Guest_Address;
                    gd.Guest_MobileNO   = details.PhoneNumber;
                    //  gd.Guest_CreditCardNo = details.Guest_CreditCardNo;
                    gd.Paasword    = hashPassword;
                    gd.Guest_Email = details.Guest_Email;

                    db.Guest_Details.Add(gd);
                    db.SaveChanges();

                    int No = Convert.ToInt32(Session["RoomNo"]);
                    return(RedirectToAction("login", "Home", new { roomNo = No }));
                }
            }
            else
            {
                ViewBag.errorss = "The Email You Entered is Already in Use.Please Use Another Email";
                return(View());
            }



            return(View());
        }
예제 #12
0
 public int Save()
 {
     return(db.SaveChanges());
 }
예제 #13
0
 public void Save()
 {
     db.SaveChanges();
 }