Esempio n. 1
0
        public virtual IEnumerable <TEntity> Get(Expression <Func <TEntity, bool> > filter = null)
        {
            IQueryable <TEntity> query = context.Set <TEntity>();

            if (filter != null)
            {
                query = query.Where(filter);
            }

            return(query.ToList());
        }
Esempio n. 2
0
 public virtual IQueryable <TEntity> GetAll()
 {
     try
     {
         return(AirportContext.Set <TEntity>());
     }
     catch (Exception ex)
     {
         throw new Exception($"Couldn't retrieve entities: {ex.Message}");
     }
 }
        public virtual Task <List <Aircraft> > GetAsync(int?filter = null)
        {
            IQueryable <Aircraft> query = Context.Set <Aircraft>().Include(c => c.AircraftType);

            if (filter != null)
            {
                query = query.Where(e => e.Id == filter);
            }

            return(query.ToListAsync());
        }
        public virtual async Task <List <Flight> > GetAsync(int?filter = null)
        {
            IQueryable <Flight> query = Context.Set <Flight>().Include(c => c.Tickets);

            if (filter != null)
            {
                query = query.Where(e => e.Id == filter);
            }

            return(await query.ToListAsync());
        }
        public virtual async Task <List <Crew> > GetAsync(int?filter = null)
        {
            IQueryable <Crew> query = Context.Set <Crew>().Include(c => c.Stewardesses).Include(c => c.Pilot);

            if (filter != null)
            {
                query = query.Where(e => e.Id == filter);
            }

            return(await query.ToListAsync());
        }
Esempio n. 6
0
        public virtual async Task <List <TEntity> > GetAsync(int?filter = null)
        {
            IQueryable <TEntity> query = Context.Set <TEntity>();

            if (filter != null)
            {
                query = query.Where(e => e.Id == filter);
            }

            return(await query.ToListAsync());
        }
        public virtual async Task <List <Departure> > GetAsync(int?filter = null)
        {
            IQueryable <Departure> query = Context.Set <Departure>().Include(c => c.Crew).Include(a => a.Aircraft).Include(f => f.Flight);

            if (filter != null)
            {
                query = query.Where(e => e.Id == filter);
            }

            return(await query.ToListAsync());
        }
Esempio n. 8
0
        public virtual List <TEntity> Get(int?filter = null)
        {
            IQueryable <TEntity> query = Context.Set <TEntity>();

            if (filter != null)
            {
                query = query.Where(e => e.Id == filter);
            }

            return(query.ToList());
        }
Esempio n. 9
0
        public virtual List <Flight> Get(int?filter = null)
        {
            IQueryable <Flight> query = Context.Set <Flight>().Include(c => c.Tickets);

            if (filter != null)
            {
                query = query.Where(e => e.Id == filter);
            }

            return(query.ToList());
        }
Esempio n. 10
0
        public async Task <UserDTO> Authentificate(string nickname, string password)
        {
            if (string.IsNullOrEmpty(nickname) || string.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("Username or password can not be empty");
            }

            var user = (await context.Set <User>().SingleOrDefaultAsync(u => u.Login == nickname));

            if (user == null || !VerifyPasswordHash(password, user.PasswordHash, user.PasswordSalt))
            {
                throw new ArgumentException("Wrong email or password");
            }
            await context.SaveChangesAsync();

            return(mapper.Map <User, UserDTO>(user));
        }
Esempio n. 11
0
 public virtual async Task <List <TEntity> > GetAll()
 {
     return(await context.Set <TEntity>().ToListAsync());
 }
Esempio n. 12
0
 public virtual T GetById(int id)
 {
     return(context.Set <T>().Find(id));
 }
Esempio n. 13
0
 public virtual IEnumerable <TEntity> Get()
 {
     return(_ctx.Set <TEntity>());
 }
Esempio n. 14
0
 public Repository(AirportContext dataContext)
 {
     DataContext = dataContext;
     DataSet     = dataContext.Set <T>();
 }
Esempio n. 15
0
 public virtual async Task <List <TEntity> > GetAsync()
 {
     return(await _ctx.Set <TEntity>().ToListAsync());
 }
Esempio n. 16
0
 public Repository(AirportContext ctx)
 {
     _ctx   = ctx;
     _dbSet = _ctx.Set <T>();
 }
Esempio n. 17
0
 public GenericRepository(AirportContext context)
 {
     this.dbSet = context.Set <TEntity>();
 }
Esempio n. 18
0
 public void Create(Crew model)
 {
     airport.Set <Crew>().Add(model);
 }