示例#1
0
 public async Task <Account> GetByUsername(string username)
 {
     using (TaskManagementDbContext context = new TaskManagementDbContext()) {
         return(await context.Accounts
                .Include(a => a.Issues)
                .FirstOrDefaultAsync(a => a.Username == username));
     }
 }
示例#2
0
        public async Task <IEnumerable <Issue> > GetAll()
        {
            using (TaskManagementDbContext context = new TaskManagementDbContext()) {
                IEnumerable <Issue> entities = await context.Issues.Include(a => a.Tasks).ToListAsync();

                return(entities);
            }
        }
示例#3
0
        public async Task <Account> Get(int id)
        {
            using (TaskManagementDbContext context = new TaskManagementDbContext()) {
                Account entity = await context.Accounts.Include(a => a.Issues).FirstOrDefaultAsync((e) => e.Id == id);

                return(entity);
            }
        }
示例#4
0
 public async Task <Account> GetByEmail(string email)
 {
     using (TaskManagementDbContext context = new TaskManagementDbContext()) {
         return(await context.Accounts
                .Include(a => a.Issues)
                .FirstOrDefaultAsync(a => a.Email == email));
     }
 }
示例#5
0
        public async Task <T> Get(int id)
        {
            using (TaskManagementDbContext context = new TaskManagementDbContext()) {
                T entity = await context.Set <T>().FirstOrDefaultAsync((e) => e.Id == id);

                return(entity);
            }
        }
示例#6
0
        public async Task <IEnumerable <T> > GetAll()
        {
            using (TaskManagementDbContext context = new TaskManagementDbContext()) {
                IEnumerable <T> entities = await context.Set <T>().ToListAsync();

                return(entities);
            }
        }
示例#7
0
        public async Task <Issue> Get(int id)
        {
            using (TaskManagementDbContext context = new TaskManagementDbContext()) {
                Issue entity = await context.Issues.Include(i => i.Tasks).FirstOrDefaultAsync((e) => e.Id == id);

                return(entity);
            }
        }
示例#8
0
        public async Task <int> Update(T entity)
        {
            using (TaskManagementDbContext context = new TaskManagementDbContext()) {
                context.Entry(entity).State = EntityState.Modified;
                await context.SaveChangesAsync();

                return(entity.Id);
            }
        }
示例#9
0
        public TaskEvents(TaskManagementDbContext activeDbContext)
        {
            if (activeDbContext == null)
            {
                throw new ArgumentNullException(nameof(activeDbContext));
            }

            ActiveDbContext = activeDbContext;
        }
示例#10
0
        public async Task <T> Create(T entity)
        {
            using (TaskManagementDbContext context = new TaskManagementDbContext()) {
                T createdEntity = context.Set <T>().Add(entity);
                await context.SaveChangesAsync();

                return(createdEntity);
            }
        }
示例#11
0
        public TaskController(TaskManagementDbContext context)
        {
            _context = context;

            if (_context.Tasks.Count() == 0)
            {
                //_context.Tasks.Add(new Task { Name = "First Task" });
                //_context.SaveChanges();
            }
        }
示例#12
0
        public async Task <bool> DeleteRange(IEnumerable <T> entities)
        {
            using (TaskManagementDbContext context = new TaskManagementDbContext()) {
                DbSet <T> items = context.Set <T>();
                for (int i = 0; i < entities.Count(); i++)
                {
                    items.Attach(entities.ElementAt(i));
                }
                items.RemoveRange(entities);
                await context.SaveChangesAsync();

                return(true);
            }
        }
示例#13
0
 public HelperController(TaskManagementDbContext context)
 {
     _context = context;
 }
 public TaskUnitRepository(TaskManagementDbContext context)
 {
     _context = context;
 }
示例#15
0
 public UserRepository(TaskManagementDbContext context) : base(context)
 {
 }
示例#16
0
 public ValueRepository(TaskManagementDbContext context) : base(context)
 {
 }
示例#17
0
 public UserRepository(TaskManagementDbContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#18
0
 public UnitOfWork(TaskManagementDbContext context)
 {
     _context = context;
 }
示例#19
0
 public AssignedUserTaskUnitRepository(TaskManagementDbContext context)
 {
     this._context = context;
 }
示例#20
0
 public TaskHistoryRepository(TaskManagementDbContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#21
0
 public ProjectController(TaskManagementDbContext context)
 {
     _context = context;
 }