コード例 #1
0
        public ActionResult Sort(string sort)
        {
            var bl         = new Dubuche.BL.RestaurantCRUD();
            var list       = Dubuche.BL.RestaurantCRUD.Casting(bl.GetAllRestaurants());
            var sortedList = list;

            //var sortedList = RestaurantSort.AlphaSorting(Dubuche.BL.RestaurantCRUD.Casting(list));
            //var downSortedList = RestaurantSort.BetaSorting(Dubuche.BL.RestaurantCRUD.Casting(list));
            //var ratedSortedList = RestaurantSort.AvgRatingSort(Dubuche.BL.RestaurantCRUD.Casting(list));
            //var topThreeSorted = RestaurantSort.AvgRatingSort(Dubuche.BL.RestaurantCRUD.Casting(list));

            try
            {
                if (sort == "byName")
                {
                    sortedList = RestaurantSort.AlphaSorting(list);
                }
                else if (sort == "byRating")
                {
                    sortedList = RestaurantSort.AvgRatingSort(list);
                }
                else if (sort == "topThree")
                {
                    sortedList = RestaurantSort.AvgRatingSort(list.Take(3).ToList());
                }
                return(View(sortedList));
            }
            catch
            {
                log = LogManager.GetLogger("mistakes");
                return(RedirectToAction("Index"));
            }
        }
コード例 #2
0
        // GET: Restaurant/Details/5
        public ActionResult Details(int id)
        {
            var bl = new Dubuche.BL.RestaurantCRUD();
            var x  = bl.GetRestaurantById(id);

            return(View(x));
        }
コード例 #3
0
        // GET: Restaurant/Delete/5
        public ActionResult Delete(int id)
        {
            var bl = new Dubuche.BL.RestaurantCRUD();

            //bl.DeleteRestaurantById(id);
            return(View(bl.GetRestaurantById(id)));
        }
コード例 #4
0
        // GET: Reviewer/Create
        public ActionResult Create()
        {
            var bl       = new Dubuche.BL.ReviewerCRUD();
            var restCrud = new Dubuche.BL.RestaurantCRUD();

            ViewBag.Rests = restCrud.GetAllRestaurants();
            return(View());
        }
コード例 #5
0
        // GET: Reviewer/Edit/5
        public ActionResult Edit(int id)
        {
            var bl       = new Dubuche.BL.ReviewerCRUD();
            var x        = bl.DisplayRestaurantReviewersById(id);
            var restCrud = new Dubuche.BL.RestaurantCRUD();

            ViewBag.Rests = restCrud.GetAllRestaurants();
            return(View(x));
        }
コード例 #6
0
        //Search
        public ActionResult Search(string Name)
        {
            var bl = new Dubuche.BL.RestaurantCRUD();

            List <Restaurant> newRestList = new List <Restaurant>();

            newRestList = bl.GetAllRestaurants();
            return(View(RestaurantSearch.Lookup(newRestList, Name)));
        }
コード例 #7
0
        // GET: Restaurant
        public ActionResult Index()
        {
            var bl = new Dubuche.BL.RestaurantCRUD();

            //var list = bl.GetAllRestaurants();

            return(View(bl.GetAllRestaurants()));

            //List<Restaurant> A
        }
コード例 #8
0
 public ActionResult Edit(int id, Restaurant restaurant2)
 {
     try
     {
         // TODO: Add update logic here
         var bl = new Dubuche.BL.RestaurantCRUD();
         bl.UpdateRestaurant(restaurant2);
         return(RedirectToAction("Index"));
     }
     catch
     {
         log = LogManager.GetLogger("mistakes");
         return(View());
     }
 }
コード例 #9
0
        public ActionResult Create(Restaurant restaurant)
        {
            try
            {
                // TODO: Add insert logic here
                var bl = new Dubuche.BL.RestaurantCRUD();
                bl.CreateRestaurant(restaurant);

                return(RedirectToAction("Index"));
            }
            catch
            {
                log = LogManager.GetLogger("mistakes");
                return(View());
            }
        }
コード例 #10
0
        public ActionResult Delete(int id, Restaurant restaurant)
        {
            try
            {
                // TODO: Add delete logic here
                var bl = new Dubuche.BL.RestaurantCRUD();
                bl.DeleteRestaurantById(id);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                log = LogManager.GetLogger("mistakes");
                log.Error($"[Restaurants Controller] [Details] Exception thrown: {e.Message}");
                return(RedirectToAction("Index"));
            }
        }