Example #1
0
        public ActionResult Dormdetail(int dorm)
        {
            DormDetailViewModel dormview = new DormDetailViewModel();

            dormview.SetDorm(dorm);

            return(View("Dormdetail", dormview));
        }
Example #2
0
        // 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));
        }
Example #3
0
        // 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));
        }
Example #4
0
 // GET: Dorm
 public ActionResult Index()
 {
     if (Session["Status"] != null)
     {
         if (Session["Status"].ToString() == "Owner")
         {
             DormDetailViewModel dt = new DormDetailViewModel();
             dt.SetDorm(Session["UserName"].ToString());
             return(View("Edit", dt));
         }
         else
         {
             return(View("Add"));
         }
     }
     else
     {
         return(Content("Error"));
     }
 }