Esempio n. 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"));
            }
        }
Esempio n. 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));
        }
Esempio n. 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)));
        }
        // GET: Reviewer/Create
        public ActionResult Create()
        {
            var bl       = new Dubuche.BL.ReviewerCRUD();
            var restCrud = new Dubuche.BL.RestaurantCRUD();

            ViewBag.Rests = restCrud.GetAllRestaurants();
            return(View());
        }
        // 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));
        }
Esempio n. 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)));
        }
Esempio n. 7
0
        // GET: Restaurant
        public ActionResult Index()
        {
            var bl = new Dubuche.BL.RestaurantCRUD();

            //var list = bl.GetAllRestaurants();

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

            //List<Restaurant> A
        }
Esempio n. 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());
     }
 }
Esempio n. 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());
            }
        }
Esempio n. 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"));
            }
        }