public ActionResult Cancel(int id) { using (System.Models.RoomSystemEntities db = new System.Models.RoomSystemEntities()) { System.Models.Reservations reservation = (from s in db.Reservations where s.Id == id select s).First(); reservation.Disable = true; db.SaveChanges(); } return(RedirectToAction("Record", "Home")); }
public ActionResult RoomDelete(int id) { using (System.Models.RoomSystemEntities db = new System.Models.RoomSystemEntities()) { string ASPNetUserID = User.Identity.GetUserId(); System.Models.AspNetUsers user = (from s in db.AspNetUsers where s.Id == ASPNetUserID select s).First(); if (user.Authority == 0) { return(View()); } System.Models.Rooms room = (from s in db.Rooms where s.Id == id select s).First(); room.Enable = false; db.SaveChanges(); } return(RedirectToAction("RoomSetting", "Home")); }
public ActionResult UsersEdit(int Authority, string Id) { using (System.Models.RoomSystemEntities db = new System.Models.RoomSystemEntities()) { string ASPNetUserID = User.Identity.GetUserId(); System.Models.AspNetUsers user = (from s in db.AspNetUsers where s.Id == ASPNetUserID select s).First(); if (user.Authority == 0) { return(View()); } if (!(Authority >= 0 && Authority < user.Authority)) { return(UsersEdit(Id)); } System.Models.AspNetUsers saveUser = (from s in db.AspNetUsers where s.Id == Id select s).First(); saveUser.Authority = Authority; db.SaveChanges(); return(RedirectToAction("UsersSetting", "Home")); } }
public ActionResult RoomEdit(RoomSystem.Models.RoomModle r) { if (!(r.MinNumberOfUsers > 0 && r.MaxNumberOfUsers > r.MinNumberOfUsers)) { return(View(r)); } using (System.Models.RoomSystemEntities db = new System.Models.RoomSystemEntities()) { string ASPNetUserID = User.Identity.GetUserId(); System.Models.AspNetUsers user = (from s in db.AspNetUsers where s.Id == ASPNetUserID select s).First(); if (user.Authority == 0) { return(View()); } System.Models.Rooms room = (from s in db.Rooms where s.Id == r.Id select s).First(); room.MinNumberOfUsers = r.MinNumberOfUsers; room.MaxNumberOfUsers = r.MaxNumberOfUsers; db.SaveChanges(); } return(RedirectToAction("RoomSetting", "Home")); }
public ActionResult RoomSetting(RoomSystem.Models.ReservationCenterModel reserveCenterModel) { using (System.Models.RoomSystemEntities db = new System.Models.RoomSystemEntities()) { string ASPNetUserID = User.Identity.GetUserId(); System.Models.AspNetUsers user = (from s in db.AspNetUsers where s.Id == ASPNetUserID select s).First(); if (user.Authority == 0) { return(View()); } bool hasReservation = (from s in db.Reservations where s.Date >= DateTime.Today && !s.Disable select s).Any(); System.Models.ReservationCenters center = (from s in db.ReservationCenters select s).First(); if (!hasReservation) { center.WeekdaysOpenTime = reserveCenterModel.WeekdaysOpenTime; center.WeekdaysCloseTime = reserveCenterModel.WeekdaysCloseTime; center.WeekendOpenTime = reserveCenterModel.WeekendOpenTime; center.WeekendCloseTime = reserveCenterModel.WeekendCloseTime; center.TimePerTimePeriod = reserveCenterModel.TimePerTimePeriod; db.SaveChanges(); } return(View(new RoomSystem.Models.ReservationCenterModel(center))); } }