public async void AddUser(UserDTO user)
 {
     using (var db = new TheaterDbContext())
     {
         db.Users.Add(new UserFactory().FromDto(user));
         await db.SaveChangesAsync();
     }
 }
 public async void AddTheaterRoom(TheaterRoomDTO theaterRoom)
 {
     using (var db = new TheaterDbContext())
     {
         db.TheaterRooms.Add(new TheaterRoomFactory().FromDto(theaterRoom));
         await db.SaveChangesAsync();
     }
 }
        public async Task <UserDTO> GetUserById(int id)
        {
            User ret;

            using (var db = new TheaterDbContext())
            {
                ret = await db.Users.FirstOrDefaultAsync(x => x.Id == id);
            }
            return(new UserFactory().ToDto(ret));
        }
Beispiel #4
0
        public async Task <IEnumerable <TheaterDTO> > GetAllTheaters()
        {
            List <Theater> ret;

            using (var db = new TheaterDbContext())
            {
                ret = await db.Theaters.ToListAsync();
            }

            return(new TheaterFactory().ToDto(ret));
        }
Beispiel #5
0
 public UnitOfWork(TheaterDbContext context)
 {
     _context = context;
     Addresses = new AddressRepository(_context);
     Orders = new OrderRepository(_context);
     Performances = new PerformanceRepository(_context);
     Questions = new QuestionRepository(_context);
     TheaterPerformances = new TheaterPerformanceRepository(_context);
     UserAnswers = new UserAnswerRepository(_context);
     Users = new UserRepository(_context);
     Variants = new VariantRepository(_context);
     Theaters = new TheaterRepository(_context);
 }
        public async void DeleteUser(int id)
        {
            using (var db = new TheaterDbContext())
            {
                var old = await db.Users.FirstOrDefaultAsync(x => x.Id == id);

                if (old == null)
                {
                    return;
                }
                db.Users.Remove(old);
                await db.SaveChangesAsync();
            }
        }
        public async Task <UserDTO> EditUser(UserDTO user)
        {
            using (var db = new TheaterDbContext())
            {
                var old = await db.Users.FirstOrDefaultAsync(x => x.Id == user.Id);

                old.Id              = user.Id;
                old.FirstName       = user.FirstName;
                old.LastName        = user.LastName;
                old.Role            = user.Role;
                db.Entry(old).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(new UserFactory().ToDto(old));
            }
        }
Beispiel #8
0
 public BaseRepository(TheaterDbContext context)
 {
     this.context = context;
 }
 public ReservationRepository(TheaterDbContext context) : base(context)
 {
 }
 public PerformanceSearchQueryBuilder(TheaterDbContext context) => _context = context;
 public VariantRepository(TheaterDbContext context) : base(context)
 {
 }
 public TheaterPerformanceQueryBuilder(TheaterDbContext context) => _context = context;
Beispiel #13
0
 public GenericRepository(TheaterDbContext context)
 {
     _context = context;
     _table   = context.Set <T>();
 }
Beispiel #14
0
 public Repository(TheaterDbContext context)
 {
     Context = context;
 }
 public ActorShowRepository(TheaterDbContext context) : base(context)
 {
 }
 public PerformanceRepository(TheaterDbContext context) : base(context)
 {
 }
Beispiel #17
0
 public QuestionRepository(TheaterDbContext context) : base(context)
 {
 }
 public TheaterRepository(TheaterDbContext context) : base(context)
 {
 }
Beispiel #19
0
 public UserAnswerRepository(TheaterDbContext context) : base(context)
 {
 }
 public TheaterSearchQueryBuilder(TheaterDbContext context) => _context = context;
 public AddressRepository(TheaterDbContext context) : base(context)
 {
 }