コード例 #1
0
        public void Restore(Task task)
        {
            var activeTasksCount = Dbset.Count(x => x.UserId == task.UserId && x.IsArchived == false);

            task.Restore(activeTasksCount);

            _context.Entry(task).State = EntityState.Modified;
            _context.SaveChanges();
        }
コード例 #2
0
        public override void Delete(PickyMessage pickyMessage)
        {
            int typeCount = Dbset.Count(x => x.Type == pickyMessage.Type);

            if (typeCount == 1)
            {
                throw new MyException("You're attempting to delete the last message of this type. I cannot allow you to do this.");
            }

            _context.Entry(pickyMessage).State = EntityState.Deleted;
            _context.SaveChanges();
        }
コード例 #3
0
        public override void Create(Task task)
        {
            if (Dbset.Any(x => x.Id != task.Id &&
                          x.UserId == task.UserId &&
                          x.Title.Equals(task.Title, StringComparison.OrdinalIgnoreCase) &&
                          x.ShortTitle.Equals(task.ShortTitle, StringComparison.OrdinalIgnoreCase) &&
                          x.Theme == task.Theme))
            {
                throw new MyException("You already have a Task with the same Title, Short Title and Theme.");
            }

            task.Order = Convert.ToInt16(Dbset.Count(x => x.UserId == task.UserId && x.IsArchived == false) + 1);
            Dbset.Add(task);
            _context.SaveChanges();
        }
コード例 #4
0
 public int CountAllWithFilters(int currentUserId, string searchName, string searchEmail)
 {
     searchName  = searchName ?? "";
     searchEmail = searchEmail ?? "";
     return(Dbset.Count(x => x.Id != currentUserId && x.Name.Contains(searchName) && x.Email.Contains(searchEmail)));
 }
コード例 #5
0
 public int CountAllWithFilters(string searchMessage, byte?searchType)
 {
     searchMessage = searchMessage ?? "";
     return(searchType.HasValue ? Dbset.Count(x => x.Message.Contains(searchMessage) && x.Type == searchType) : Dbset.Count(x => x.Message.Contains(searchMessage)));
 }
コード例 #6
0
 public int CountAllByUserId(int userId, bool isArchived)
 {
     return(Dbset.Count(x => x.UserId == userId && x.IsArchived == isArchived));
 }
コード例 #7
0
        public int GetTotalRegistros()
        {
            var _object = CompiledQuery.Compile <ObjectContext, int>(ctx => Dbset.Count());

            return(_object.Invoke(((IObjectContextAdapter)Entities).ObjectContext));
        }