Пример #1
0
        public async Task <T> CreteAsync(T newItem)
        {
            await context.Set <T>().AddAsync(newItem);

            await context.SaveChangesAsync();

            return(newItem);
        }
Пример #2
0
        public async Task <Guid> Create(TEntity entity)
        {
            await authContext.Set <TEntity>().AddAsync(entity);

            await authContext.SaveChangesAsync();

            return(entity.Id);
        }
Пример #3
0
        public Task <int> DeleteAsync <TEntity>(TEntity entity) where TEntity : class
        {
            DbEntityEntry dbEntityEntry = context.Entry(entity);

            if (dbEntityEntry.State != EntityState.Deleted)
            {
                dbEntityEntry.State = EntityState.Deleted;
            }
            else
            {
                context.Set <TEntity>().Attach(entity);
                context.Set <TEntity>().Remove(entity);
            }
            return(Task.FromResult(1));
        }
Пример #4
0
 public IEnumerable <TEntity> GetAll()
 {
     try
     {
         return(_vehicleContextContext.Set <TEntity>());
     }
     catch (Exception ex)
     {
         throw new Exception($"Couldn't retrieve entities: {ex.Message}");
     }
 }
Пример #5
0
        public Task <IEnumerable <TEntity> > Handle(TQuery request, CancellationToken cancellationToken)
        {
            var entites = _context.Set <TEntity>().AsEnumerable();

            if (entites == null)
            {
                throw new CustomException(HttpStatusCode.NotFound, new { entites = "No Vehicles Found" });
            }

            return(Task.FromResult(entites));
        }
Пример #6
0
 public Repository(VehicleContext context)
 {
     _context   = context;
     this.dbSet = context.Set <TEntity>();
 }
Пример #7
0
 public void EditVehicleMake(MakeView makeView)
 {
     context.Set <VehicleMake>().AddOrUpdate(Mapper.Map <VehicleMake>(makeView));
     context.SaveChanges();
 }
 public PaymentRepository(VehicleContext context)
 {
     Context  = context;
     Entities = Context.Set <CustomerBankAccount>();
 }
Пример #9
0
 public GenericRepository(VehicleContext context)
 {
     _context = context;
     dbSet    = _context.Set <T>();
 }
 public VehiclesForSaleRepository(IUnitOfWork unitOfWork, VehicleContext context)
 {
     this.UnitOfWork = unitOfWork;
     this.Context    = context;
     SaleEntities    = Context.Set <VehiclesForSale>();
 }
 public GenericRepository(VehicleContext context)
 {
     this.Context = context;
     Entities     = Context.Set <TEntity>();
 }
 public ItemsInStockRepository(IUnitOfWork unitOfWork, VehicleContext context)
 {
     UnitOfWork    = unitOfWork;
     Context       = context;
     StockEntities = Context.Set <ItemsInStockModel>();
 }
Пример #13
0
 public IQueryable <TEntity> GetAll <TEntity>() where TEntity : class
 {
     return(context.Set <TEntity>());
 }
Пример #14
0
 public CartRepository(VehicleContext context)
 {
     Context       = context;
     CartEntities  = Context.Set <Cart>();
     StockEntities = Context.Set <ItemsInStockModel>();
 }
Пример #15
0
 public UserDetailsRepository(VehicleContext context)
 {
     Context  = context;
     Entities = Context.Set <UserDetails>();
 }
 /// <summary>
 /// This a Contructor Generic Repository
 /// </summary>
 /// <param name="entities">Is a element from database</param>
 protected GenericRepositoryEntities(VehicleContext entities)
 {
     _entities = entities;
     Dbset     = entities.Set <T>();
     //
 }
Пример #17
0
 public BaseRepository(VehicleContext context)
 {
     Db    = context;
     DbSet = Db.Set <TEntity>();
 }