public static List<CategoryDTO> GetFavoriteCategoryList() { using (restaurantEntities db = new restaurantEntities()) { List<MenuDTO> lfMenu = MenuBL.GetFavoriteMenu(); List<Category> Listnew = new List<Category>(); foreach (var item in lfMenu) { var r = Listnew.FirstOrDefault(x => x.Id == item.Category); if (r == null) { Listnew.Add(db.Category.FirstOrDefault(x => x.Id == item.Category)); } } //List<Category> List = db.Category.Where(x => lNewMenu.Any(y => x.Id == y.Category)).ToList(); return CategoryCast.ListToDTO(Listnew); } }
public static List <InventDoseDTO> GetAll() { var dal = InventDoseDAL.GetAll(); List <InventDoseDTO> dalList = new List <InventDoseDTO>(); foreach (var item in dal) { var i = InventDoseCast.ToDTO(item); i.StatusName = InventDoseDAL.GetByIdStatusInvent(i.IdStatusInvent).Kind.Trim(); i.VisiterName = VisitersDAL.GetById(i.IdVisiter).FirstName; i.InventDetails = InventDetailsCast.ListToDTO(InventDoseDAL.GetByIdInventDetails(i.Id)); foreach (var menu in i.InventDetails) { var m = MenuBL.GetById(menu.IdMenu); menu.MenuName = m.NameDose; } dalList.Add(i); } return(dalList); }
public static List <FavoriteDose> getDoseByfeedback() { List <FavoriteDose> favorite = new List <FavoriteDose>(); var list = InventDoseCast.ListToDTO(InventDoseDAL.GetDoseByfeedback()); foreach (var item in list) { var f = new FavoriteDose(); var name = VisitersDAL.GetById(item.IdVisiter); f.VisiterName = name.FirstName.Trim() + " " + name.LastName.Trim(); f.Feedback = item.Feedback.Trim(); f.date = DateTime.Now; f.rate = item.rate; item.InventDetails = InventDetailsCast.ListToDTO(InventDoseDAL.GetByIdInventDetails(item.Id)); foreach (var menu in item.InventDetails) { f.Menu = MenuBL.GetById(menu.IdMenu); } favorite.Add(f); } return(favorite); }