public void SetDorm(string name) { DormLayer layer = new DormLayer(); dorm = layer.GetDorm(name); SetImage(); }
public void SetDorm(int id) { DormLayer layer = new DormLayer(); dorm = layer.GetDorm(id); SetImage(); }
private bool isOwner(string name) { DormLayer dormBal = new DormLayer(); List <Dorm> dorms = dormBal.GetDorm(); foreach (Dorm dorm in dorms) { if (dorm.M_username == name) { return(true); } } return(false); }
//send message to all room public ActionResult CheckAllRoom(MessageHTML m) { MessageLayer memlayer = new MessageLayer(); List <Message> mlist = memlayer.GetMessage(); DormLayer layer = new DormLayer(); Dorm dorm = layer.GetDorm(Session["UserName"].ToString()); int sender_dorm = dorm.Dorm_ID; int mlistid = mlist.Count; Message mem = new Message(); RoomLayer RoomDB = new RoomLayer(); List <Room> RoomList = RoomDB.GetStatusRoom(); //only room that have person live foreach (Room r in RoomList) { if (r.Dorm_ID == sender_dorm) { PersonLayer PL = new PersonLayer(); List <Person> personoomList = PL.GetPerson(); foreach (Person person in personoomList) { if (person.Room_ID == r.Room_ID) { mem = new Message(); mem.Receiver_Username = person.Username; mem.Sender_Username = Session["UserName"].ToString(); mem.MessageID = mlistid + 1; mem.Title = m.Subject; mem.Text = m.Message; mem.Isread = 0; mem.Date = DateTime.Now.ToString("dd-MM-yyyy") + " " + DateTime.Today.ToString("HH:mm:ss tt"); //Date + Time db.Message.Add(mem); db.SaveChanges(); mlistid++; } } } } //return mem.Receiver_Username + " " + mem.Sender_Username + " " + // " " + mem.Date ; return(RedirectToAction("index", new { action = 1 })); }
// Search Page MuMu Dont Touch = - =-------------------------------------- public ActionResult ViewSearch(string dname, string Dormoption) { DormLayer DormDB = new DormLayer(); List <Dorm> DormList = DormDB.GetDorm(); List <Dorm> DormSearch = new List <Dorm>(); foreach (Dorm dorm in DormList) { if (dorm.Name.Contains(dname)) { DormSearch.Add(dorm); } } List <DormDetailViewModel> Dormviewmodel = new List <DormDetailViewModel>(); foreach (Dorm dorm in DormSearch) { DormDetailViewModel dormview = new DormDetailViewModel(); dormview.SetDorm(dorm.Dorm_ID); Dormviewmodel.Add(dormview); } if (Dormoption == "pricemin") { //max->min Dormviewmodel.Sort(delegate(DormDetailViewModel c1, DormDetailViewModel c2) { return(c1.minPrice.CompareTo(c2.minPrice)); }); } else if (Dormoption == "pricemax") { //min->max Dormviewmodel.Sort(delegate(DormDetailViewModel c1, DormDetailViewModel c2) { return(c2.minPrice.CompareTo(c1.minPrice)); }); } else if (Dormoption == "ratemax") { Dormviewmodel.Sort(delegate(DormDetailViewModel c1, DormDetailViewModel c2) { return(c2.avgRate.CompareTo(c1.avgRate)); }); } else if (Dormoption == "ratemin") { Dormviewmodel.Sort(delegate(DormDetailViewModel c1, DormDetailViewModel c2) { return(c1.avgRate.CompareTo(c2.avgRate)); }); } return(View("Searchpage", Dormviewmodel)); }
// Search Page MuMu Dont Touch = - =-------------------------------------- public ActionResult Index(string dname) { DormLayer DormDB = new DormLayer(); List <Dorm> DormList = DormDB.GetDorm(); List <DormDetailViewModel> Dormviewmodel = new List <DormDetailViewModel>(); foreach (Dorm dorm in DormList) { DormDetailViewModel dormview = new DormDetailViewModel(); dormview.SetDorm(dorm.Dorm_ID); Dormviewmodel.Add(dormview); } return(View("Searchpage", Dormviewmodel)); }
public ActionResult FeedbackSubmit(string detail_feedback) { JongHorDBEntities1 db = new JongHorDBEntities1(); DormLayer layer = new DormLayer(); PersonBusinessLayer personLayer = new PersonBusinessLayer(); MessageLayer memlayer = new MessageLayer(); List <Message> mlist = memlayer.GetMessage(); int mlistid = mlist.Count; Person user = personLayer.GetUser(Session["UserName"].ToString()); Message message = new Message(); message.Receiver_Username = layer.GetDorm(user.Dorm_ID.Value).Person.Username; message.Sender_Username = user.Username; message.MessageID = mlistid + 1; message.Title = "Feedback"; Room room = user.Room; message.Text = (room.Floor + "" + room.Room_ID) + ": " + detail_feedback; message.Isread = 0; message.Date = DateTime.Now.ToString("dd-MM-yyyy") + " " + DateTime.Today.ToString("HH:mm:ss tt"); //Date + Time db.Message.Add(message); try { db.SaveChanges(); } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); // Join the list to a single string. var fullErrorMessage = string.Join("; ", errorMessages); // Combine the original exception message with the new one. var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage); // Throw a new DbEntityValidationException with the improved exception message. throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors); } Response.Write("<script>alert('Message has been sent')</script>"); return(Index()); }
//send message to specific room public ActionResult CheckSpecificRoom(MessageHTML m, string receiver) { Message mem = new Message(); bool CheckRoom = false; string NotFoundRoom = "This room is available"; MessageLayer memlayer = new MessageLayer(); List <Message> mlist = memlayer.GetMessage(); DormLayer layer = new DormLayer(); Dorm dorm = layer.GetDorm(Session["UserName"].ToString()); int sender_dorm = dorm.Dorm_ID; /// scan username of room RoomLayer Rl = new RoomLayer(); List <Room> roomList = Rl.GetStatusRoom(); //get only unavailable room foreach (Room room in roomList) { if (room.Dorm_ID == sender_dorm) { //int.Parse(receiver) String roomnum = room.Floor + room.Room_number; if (roomnum == receiver) { PersonLayer PL = new PersonLayer(); List <Person> personoomList = PL.GetPerson(); foreach (Person person in personoomList) { if (person.Room_ID == room.Room_ID) { mem.Receiver_Username = person.Username; CheckRoom = true; } } } } } /// mem.Sender_Username = Session["UserName"].ToString(); mem.MessageID = mlist.Count + 1; mem.Title = m.Subject; mem.Isread = 0; mem.Text = m.Message; mem.Date = DateTime.Now.ToString("dd-MM-yyyy") + " " + DateTime.Today.ToString("HH:mm:ss tt"); //Date + Time if (CheckRoom == true) { db.Message.Add(mem); db.SaveChanges(); return(RedirectToAction("Index", new { action = 1 })); } else { return(View("Messenger")); //return NotFoundRoom; } // return mem.Receiver_Username + " " + mem.Sender_Username + " " + // " " + mem.Date; }