public PersonUserService(VehicleDiaryDbContext vehicleDiaryDbContext, IEventAggregator eventAggregator)
 {
     _context         = vehicleDiaryDbContext;
     _eventAggregator = eventAggregator;
     _eventAggregator.Subscribe(this);
     Vehicles = new List <VehicleModel>();
 }
Пример #2
0
        public async Task <T> Update(T entity)
        {
            _context = new VehicleDiaryDbContext();
            _context.Set <T>().AddOrUpdate(entity);
            await _context.SaveChangesAsync();

            return(entity);
        }
Пример #3
0
        public async Task <T> Create(T entity)
        {
            _context = new VehicleDiaryDbContext();
            var res = _context.Set <T>().Add(entity);
            await _context.SaveChangesAsync();

            return(res);
        }
Пример #4
0
        public async Task <bool> Delete <S>(S id)
        {
            // overkill reflection attempt
            // var idType = id.GetType();
            // var idProperty = idType.GetProperty(propertyName);
            _context = new VehicleDiaryDbContext();
            T res = await _context.Set <T>().FindAsync(id);

            _context.Set <T>().Remove(res);
            await _context.SaveChangesAsync();

            return(true);
        }
 public ServiceUserService(VehicleDiaryDbContext vehicleDiaryDbContext)
 {
     _context        = vehicleDiaryDbContext;
     VehicleServices = new List <VehicleServiceModel>();
 }
 public VehicleService(VehicleDiaryDbContext vehicleDiaryDbContext)
 {
     _context     = vehicleDiaryDbContext;
     SaleListings = new List <SaleListingModel>();
 }
 public UserService(VehicleDiaryDbContext vehicleDiaryDbContext)
 {
     _context = vehicleDiaryDbContext;
 }
Пример #8
0
 public async Task <IEnumerable <T> > GetAll()
 {
     _context = new VehicleDiaryDbContext();
     return(await _context.Set <T>().ToListAsync());
 }
Пример #9
0
 public Task <T> Get <S>(S id)
 {
     _context = new VehicleDiaryDbContext();
     return(_context.Set <T>().FindAsync(id));
 }