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()); } }
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)); }
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)); }
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)); }
public void AddClient(clients client) { using (HotelModel context = new HotelModel()) { if (client != null) { context.clients.Add(client); context.SaveChanges(); } } }
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(); } } }
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)); }
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(); } } }
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()); }
public int Save() { return(db.SaveChanges()); }
public void Save() { db.SaveChanges(); }