public ActionResult insertComment(Comment model)
 {
     Account AccountModel = new Account();
     AccountModel.username = User.Identity.Name;
     AccountRepository _accountRepository = new AccountRepository(AccountModel);
     model.UserID = _accountRepository.getData().ID;
     model.CommentDateTime = DateTime.Now;
     CommentRepository _commentRepository = new CommentRepository(model);
     _commentRepository.insertComment();
     return RedirectToAction("SearchResultDetail", "Room", new { id = model.RoomID });
 }
 public CommentRepository(Comment _comment)
 {
     this._comment = _comment;
 }
 public Room getdata()
 {
     Room _RoomAccount = new Room();
     SqlCeCommand cmd = new SqlCeCommand("Select * from RoomInformation " +
                                         "inner join Comment on RoomInformation.RoomID = Comment.RoomID " +
                                         "inner join UserInformation on RoomInformation.UserID = UserInformation.User_ID " +
                                         "inner join UserInformation As CommentAccount on Comment.UserID = CommentAccount.User_ID " +
                                         "where RoomInformation.RoomID =@RoomID Order by Comment.CommentDateTime DESC", conn);
     cmd.Parameters.AddWithValue("@RoomID", this.roominformation.RoomID);
     SqlCeDataAdapter adapter = new SqlCeDataAdapter();
     adapter.SelectCommand = cmd;
     DataSet setdata = new DataSet();
     adapter.Fill(setdata, "RoomInformation");
     if (setdata.Tables[0].Rows.Count > 0)
     {
         _RoomAccount.RoomID = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[0].ToString());
         _RoomAccount.ApartmentName = setdata.Tables[0].Rows[0].ItemArray[1].ToString();
         _RoomAccount.RoomForSale = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[2].ToString());
         _RoomAccount.RoomForRent = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[3].ToString());
         _RoomAccount.RoomType = setdata.Tables[0].Rows[0].ItemArray[4].ToString();
         _RoomAccount.RoomSize = setdata.Tables[0].Rows[0].ItemArray[5].ToString();
         _RoomAccount.RoomPrice = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[6].ToString());
         _RoomAccount.District = setdata.Tables[0].Rows[0].ItemArray[7].ToString();
         _RoomAccount.Tambon = setdata.Tables[0].Rows[0].ItemArray[8].ToString();
         _RoomAccount.Road = setdata.Tables[0].Rows[0].ItemArray[9].ToString();
         _RoomAccount.Soi = setdata.Tables[0].Rows[0].ItemArray[10].ToString();
         _RoomAccount.PostCode = setdata.Tables[0].Rows[0].ItemArray[11].ToString();
         _RoomAccount.FullAddress = setdata.Tables[0].Rows[0].ItemArray[12].ToString();
         _RoomAccount.ElecPerUnit = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[13].ToString());
         _RoomAccount.WaterPerUnit = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[14].ToString());
         _RoomAccount.RoomStatus = setdata.Tables[0].Rows[0].ItemArray[15].ToString();
         _RoomAccount.AirCon = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[16].ToString());
         _RoomAccount.Fridge = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[17].ToString());
         _RoomAccount.Balcony = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[18].ToString());
         _RoomAccount.Tv = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[19].ToString());
         _RoomAccount.Internet = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[20].ToString());
         _RoomAccount.WHeater = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[21].ToString());
         _RoomAccount.Pets = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[22].ToString());
         _RoomAccount.Fitness = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[23].ToString());
         _RoomAccount.Swimming = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[24].ToString());
         _RoomAccount.Laundry = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[25].ToString());
         _RoomAccount.Store = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[26].ToString());
         _RoomAccount.Elevator = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[27].ToString());
         _RoomAccount.Parking = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[28].ToString());
         _RoomAccount.FrontDesk = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[29].ToString());
         _RoomAccount.KeyCard = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[30].ToString());
         _RoomAccount.FingerPrint = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[31].ToString());
         _RoomAccount.CCTV = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[32].ToString());
         _RoomAccount.Guard = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[33].ToString());
         _RoomAccount.FireAlarm = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[34].ToString());
         _RoomAccount.UserID = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[35].ToString());
         _RoomAccount.Username = setdata.Tables[0].Rows[0].ItemArray[48].ToString();
         for (int i = 0; i < setdata.Tables[0].Rows.Count; i++)
         {
             Comment _comment = new Comment();
             _comment.CommentID = Int64.Parse(setdata.Tables[0].Rows[i].ItemArray[36].ToString());
             _comment.Username = setdata.Tables[0].Rows[i].ItemArray[61].ToString();
             _comment.CommentContent = setdata.Tables[0].Rows[i].ItemArray[39].ToString();
             _comment.CommentDateTime = DateTime.Parse(setdata.Tables[0].Rows[0].ItemArray[40].ToString());
             _RoomAccount.RoomCommentList.Add(_comment);
         }
     }
     return _RoomAccount;
 }
 public ActionResult comment(Int64 RoomID)
 {
     Comment model = new Comment();
     model.RoomID = RoomID;
     return PartialView(model);
 }