public IQueryable <Event> Get(EventType?type, bool includeAll = true) { switch (type) { case EventType.Concert: { return(ConcertRepository.Get(null, includeProperties: includeAll?_concertsIncludes: string.Empty)); } case EventType.Exhibition: { return(ExhibitionRepository.Get(null, includeProperties: includeAll?_exhibitionsIncludes: string.Empty)); } case EventType.Movie: { return(MovieRepository.Get(null, includeProperties: includeAll?_moviesIncludes: string.Empty)); } case EventType.Performance: { return(PerformanceRepository.Get(null, includeProperties: includeAll?_performancesIncludes: string.Empty)); } case EventType.Sport: { return(SportRepository.Get(null, includeProperties: includeAll?_sportIncludes: string.Empty)); } default: return(GetAll(includeAll)); } }
public void QueryPerformanceTest() { var performanceResults = PerformanceRepository.GetAll(); //assert Assert.AreNotEqual(performanceResults.Count, 0); }
public UnitOfWork(ApplicationContext context) { _context = context; Users = new UserRepository(context); Performances = new PerformanceRepository(context); Purchases = new PurchaseRepository(context); Tickets = new TicketRepository(context); Vouchers = new VoucherRepository(context); Orders = new OrderRepository(context); Products = new ProductRepository(context); OrdersProducts = new OrderProductRepository(context); }
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 List <PerformanceVM> GetUpcomingPerformances() { var performances = new List <PerformanceVM>(); using (var db = new ManagementToolProjectEntities()) { var resp = new PerformanceRepository(db); var perfs = resp.Get(p => p.Date > DateTime.Now && p.Event.status == 1).OrderBy(o => o.Date).Take(5); var transformer = new PerformanceTransformer(); performances = transformer.Transform(perfs); } return(performances); }
public PerformanceVM GetPerformance(int id) { var performance = new PerformanceVM(); using (var db = new ManagementToolProjectEntities()) { var resp = new PerformanceRepository(db); var perf = resp.GetFirstOrDefault(p => p.PerformanceId == id); var transformer = new PerformanceTransformer(); performance = transformer.Transform(perf); } return(performance); }
public List <PerformanceVM> GetPerformances(int id) { var performances = new List <PerformanceVM>(); using (var db = new ManagementToolProjectEntities()) { var resp = new PerformanceRepository(db); var perfs = resp.Get(p => p.EventId == id); var transformer = new PerformanceTransformer(); performances = transformer.Transform(perfs); } return(performances); }
public void InsertPerformanceTest() { //Assign var performance = new Performance { ID = 15, CpuValue = 13, MemValue = 8, SampleDate = DateTime.Now }; //Act var success = PerformanceRepository.Save(performance); //Assert Assert.AreEqual(success, true); }
public static bool Save(int cpuValue, int memValue, DateTime sampleDate) { try { //this should be in the Performance class, but as this project is going EF database first, that class is generated var performance = new Performance { CpuValue = cpuValue, MemValue = memValue, SampleDate = sampleDate }; return(PerformanceRepository.Save(performance)); } catch (Exception ex) { WriteLog(ex); } return(false); }
public bool UpdatePerformance(PerformanceVM model) { var success = false; using (var db = new ManagementToolProjectEntities()) { var resp = new PerformanceRepository(db); Performance perf = resp.GetFirstOrDefault(p => p.PerformanceId == model.PerformanceId); perf.Date = DateTime.Parse(model.PerformanceDate); perf.Price = model.Price; perf.status = model.Cancelled; perf.TotalTickets = model.AvailableTickets; perf.EventId = model.EventId; resp.Update(perf); success = db.SaveChanges() > 0; } return(success); }
public IQueryable <Event> GetAll(bool includeAll = true) { //temporary solution caused by ef bug IEnumerable <Event> events = new List <Event>(); events = events.Concat(ConcertRepository .Get(null, includeProperties: includeAll ? _concertsIncludes : string.Empty) .ToList()) .Concat(MovieRepository .Get(null, includeProperties: includeAll ? _moviesIncludes : string.Empty) .ToList()) .Concat(SportRepository .Get(null, includeProperties: includeAll ? _sportIncludes : string.Empty) .ToList()) .Concat(PerformanceRepository .Get(null, includeProperties: includeAll ? _performancesIncludes : string.Empty) .ToList()) .Concat(ExhibitionRepository .Get(null, includeProperties: includeAll ? _exhibitionsIncludes : string.Empty) .ToList()); return(events.AsQueryable()); }
public bool CreatePerformance(PerformanceVM model) { var success = false; using (var db = new ManagementToolProjectEntities()) { var resp = new PerformanceRepository(db); var perf = new Performance { Date = DateTime.Parse(model.PerformanceDate), EventId = model.EventId, Price = model.Price, status = model.Cancelled, TotalTickets = model.AvailableTickets }; resp.Insert(perf); success = db.SaveChanges() > 0; } return(success); }
public static bool Save(Performance performance) { return(PerformanceRepository.Save(performance)); }
public static IList <Performance> GetAll() { return(PerformanceRepository.GetAll()); }