示例#1
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
      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);
      }
示例#5
0
        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());;
        }
示例#6
0
        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)));
        }
示例#7
0
        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)));
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
        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);
        }
示例#11
0
        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);
        }