Ejemplo n.º 1
0
 public static List <MenuDTO> GetANewMenu()
 {
     using (restaurantEntities db = new restaurantEntities())
     {
         //Where(u => u.DateAdded < DateTime.Today.AddDays(-8)).
         List <Menu> newM = db.Menu.Where(u => DateTime.Compare(u.DateAdded.Value, DateTime.Now) > 1).ToList();
         return(MenuCast.ListToDTO(newM));
     }
 }
Ejemplo n.º 2
0
 //חישוב המנות עם הדירוג הגבוהה ביתר
 public static List <MenuDTO> GetFavoriteMenu()
 {
     using (restaurantEntities db = new restaurantEntities())
     {
         int?TotalsumRating            = 0;
         int?sumRating                 = 0;
         List <RatingMenu> LRatingMenu = new List <RatingMenu>();
         RatingMenu        ratingM     = new RatingMenu();
         List <Menu>       menuList    = db.Menu.ToList();
         foreach (var menu in menuList)
         {
             ratingM        = new RatingMenu();
             TotalsumRating = 0;
             sumRating      = 0;
             List <Rating> ratingList = db.Rating.Where(m => m.doseId == menu.Id).ToList();
             foreach (var r in ratingList)
             {
                 sumRating++;
                 TotalsumRating += r.rate;
             }
             if (TotalsumRating != 0)
             {
                 ratingM.MenuID = menu.Id;
                 ratingM.Rate   = TotalsumRating / sumRating;
                 LRatingMenu.Add(ratingM);
             }
         }
         var         c    = LRatingMenu.OrderByDescending(u => u.Rate).Take(5).ToList();
         List <Menu> List = new List <Menu>();
         foreach (var item in c)
         {
             Menu m = db.Menu.FirstOrDefault(t => t.Id == item.MenuID);
             if (List.FirstOrDefault(w => w.Id == m.Id) == null)
             {
                 List.Add(m);
             }
         }
         return(MenuCast.ListToDTO(List));
     }
 }
Ejemplo n.º 3
0
 public static List <MenuDTO> GetByCategory(int id)
 {
     return(MenuCast.ListToDTO(MenuDAL.GetByCategory(id)));
 }
Ejemplo n.º 4
0
 public static List <MenuDTO> GetAll()
 {
     return(MenuCast.ListToDTO(MenuDAL.GetAll()));
 }