public IEnumerable <CommentGetModel> GetAllComments(string filterText) { IQueryable <Expense> result = context.Expenses.Include(c => c.Comments); List <CommentGetModel> resultComments = new List <CommentGetModel>(); List <CommentGetModel> resultCommentsNoFilter = new List <CommentGetModel>(); foreach (Expense expense in result) { expense.Comments.ForEach(comment => { CommentGetModel newComment = CommentGetModel.ConvertToCommentsGetModel(comment, expense); if (comment.Text == null || filterText == null) { resultCommentsNoFilter.Add(newComment); } else if (comment.Text.Contains(filterText)) { resultComments.Add(newComment); } }); } //dysplay result if (filterText == null) { return(resultCommentsNoFilter); } return(resultComments); }
//public IEnumerable<CommentGetModel> GetAll(string filter) //{ // IQueryable<Comment> result = context.Comments; // result = result.Where(c => c.Text.Contains(filter)); // return result.Select(c => CommentGetModel.FromComment(c)); //} public IEnumerable <CommentGetModel> GetAll(string filter) { IQueryable <Movie> result = context.Movies.Include(c => c.Comments); List <CommentGetModel> resultComments = new List <CommentGetModel>(); foreach (Movie m in result) { m.Comments.ForEach(c => { if (c.Text.Contains(filter)) { CommentGetModel comment = new CommentGetModel { Id = c.Id, Important = c.Important, Text = c.Text, MovieId = m.Id }; resultComments.Add(comment); } }); } return(resultComments); }
public IEnumerable <CommentGetModel> GetAll(string filter) { IQueryable <Expense> result = context.Expenses.Include(c => c.Comments); List <CommentGetModel> resultComments = new List <CommentGetModel>(); List <CommentGetModel> resultCommentsNoFilter = new List <CommentGetModel>(); //foreach (Expense e in result) //{ // e.Comments.ForEach(c => // { // if (c.Text == null || filter == null) // { // CommentGetModel comment = new CommentGetModel // { // Important = c.Important, // Text = c.Text, // ExpenseId = e.Id // }; // resultCommentsNoFilter.Add(comment); // } // else if (c.Text.Contains(filter)) // { // CommentGetModel comment = new CommentGetModel // { // Important = c.Important, // Text = c.Text, // ExpenseId = e.Id // }; // resultComments.Add(comment); // } // }); //} foreach (Expense expense in result) { expense.Comments.ForEach(comment => { CommentGetModel newComment = CommentGetModel.FromComment(comment, expense); if (comment.Text == null || filter == null) { resultCommentsNoFilter.Add(newComment); } else if (comment.Text.Contains(filter)) { resultComments.Add(newComment); } }); } if (filter == null) { return(resultCommentsNoFilter); } return(resultComments); }
public IEnumerable <CommentGetModel> GetAll(string filter) { //IQueryable<Comment> result = context.Comments; ////.Include(f => f.Comments); //if (filter != null) //{ // result = result.Where(f => f.Text.Contains(filter)); //} //return result.Select(f => CommentGetModel.FromComment(f)); ; List <CommentGetModel> list = new List <CommentGetModel>(); List <CommentGetModel> list2 = new List <CommentGetModel>(); IQueryable <Expense> result = context.Expenses.Include(f => f.Comments); //result = result // .Where(e => e.Comments // .Any(c => c.Text.Contains(filter))); if (filter == null) { foreach (Expense e in result) { var temp = e.Comments; foreach (Comment c in temp) { { var m = new CommentGetModel { ExpenseId = e.Id, Id = c.Id, Text = c.Text, Important = c.Important }; list2.Add(m); } } } return(list2); } foreach (Expense e in result) { var temp = e.Comments; foreach (Comment c in temp) { if (c.Text.Contains(filter) && filter != null) { var m = new CommentGetModel { ExpenseId = e.Id, Id = c.Id, Text = c.Text, Important = c.Important }; list.Add(m); } } } return(list); }
public IEnumerable <CommentGetModel> GetAll(string filterString) { IQueryable <Comment> result = context .Comments .Where(c => string.IsNullOrEmpty(filterString) || c.Text.Contains(filterString)) .Include(c => c.Taskul); return(result.Select(t => CommentGetModel.FromComment(t)).ToList());; }
private IQueryable <CommentGetModel> GetCommentAndMovie() { var commentAndMovie = from comment in dbContext.Comment join movie in dbContext.Movies on comment.MovieId equals movie.Id select new CommentGetModel() { Id = comment.Id, Text = comment.Text, Important = comment.Important, MovieId = comment.MovieId }; return(dbContext.Comment.Select(comment => CommentGetModel.FromComment(comment))); }
public IEnumerable <CommentGetModel> GetAllComentsAndTask() { var order = from comment in context.Comments join task in context.Tasks on comment.TaskId equals task.Id select new CommentGetModel() { Id = comment.Id, Text = comment.Text, Important = comment.Important, TaskId = comment.TaskId }; return(context.Comments.Select(comment => CommentGetModel.DinTask(comment))); }
public PaginatedList <CommentGetModel> GetAll(int page, string filter) { IQueryable <Comment> result = context .Comment .Where(c => string.IsNullOrEmpty(filter) || c.Text.Contains(filter)) .OrderBy(c => c.Id) .Include(c => c.Expense); var paginatedResult = new PaginatedList <CommentGetModel>(); paginatedResult.CurrentPage = page; paginatedResult.NumberOfPages = (result.Count() - 1) / PaginatedList <CommentGetModel> .EntriesPerPage + 1; result = result .Skip((page - 1) * PaginatedList <CommentGetModel> .EntriesPerPage) .Take(PaginatedList <CommentGetModel> .EntriesPerPage); paginatedResult.Entries = result.Select(c => CommentGetModel.FromComment(c)).ToList(); return(paginatedResult); }
public IEnumerable <CommentGetModel> GetAll(String filter) { IQueryable <Expense> result = context.Expenses.Include(c => c.Comments); List <CommentGetModel> resultFilteredComments = new List <CommentGetModel>(); List <CommentGetModel> resultAllComments = new List <CommentGetModel>(); foreach (Expense expense in result) { expense.Comments.ForEach(c => { if (c.Text == null || filter == null) { CommentGetModel comment = new CommentGetModel { Id = c.Id, Important = c.Important, Text = c.Text, ExpenseId = expense.Id }; resultAllComments.Add(comment); } else if (c.Text.Contains(filter)) { CommentGetModel comment = new CommentGetModel { Id = c.Id, Important = c.Important, Text = c.Text, ExpenseId = expense.Id }; resultFilteredComments.Add(comment); } }); } if (filter == null) { return(resultAllComments); } return(resultFilteredComments); }
public IEnumerable <CommentGetModel> GetAll(String filter) { IQueryable <Taskk> result = context.Tasks.Include(c => c.Comments); List <CommentGetModel> resultComments = new List <CommentGetModel>(); List <CommentGetModel> resultCommentsAll = new List <CommentGetModel>(); foreach (Taskk task in result) { task.Comments.ForEach(c => { if (c.Text == null || filter == null) { CommentGetModel comment = new CommentGetModel { Id = c.Id, Important = c.Important, Text = c.Text, TaskId = task.Id }; resultCommentsAll.Add(comment); } else if (c.Text.Contains(filter)) { CommentGetModel comment = new CommentGetModel { Id = c.Id, Important = c.Important, Text = c.Text, TaskId = task.Id }; resultComments.Add(comment); } }); } if (filter == null) { return(resultCommentsAll); } return(resultComments); }
public IEnumerable <CommentGetModel> GetAllFiltered(string filter) { bool filterComment = true; if (string.IsNullOrEmpty(filter)) { filterComment = false; } var IQueryable <CommentGetModel> result = context .Comments .Select(c => CommentGetModel.DinTask(c)) .Where(c => c.Text.Contains(filter)); //if (filter.Equals(null)) //{ // return result.Select(t => CommentGetModel.DinTask(comment); //} return(result); }