public RemoveEventViewModel(TicketService serviceT, ConcertService serviceC) { tService = serviceT; cService = serviceC; Concerts = new ObservableCollection <ConcertDTO>(cService.GetAll()); DeleteConcertCommand = new RelayCommand(x => { int b = 0; foreach (var i in tService.GetAll()) { if (i.ConcertId == SelectedConcert.Id) { b++; } } if (b == 0) { ErrorText = ""; cService.Delete(SelectedConcert); } else { ErrorText = "Нельзя удалить. Имеются билеты с указанным концертом"; } Switcher.Switch(new ListEventView()); }); }
private ConcertService CreateConcertService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ConcertService(userId); return(service); }
public ConcertsViewModel() { Title = "Концерти"; ConcertTreshold = 4; pageNumber = 1; concertService = new ConcertService(); Concerts = new ObservableCollection <Concert>(); FilteredConcerts = new ObservableCollection <Concert>(); LoadConcertsCommand = new Command(async() => await ExecuteLoadConcertsCommand()); ConcertTresholdReachedCommand = new Command(async() => await ConcertsTresholdReached()); RefreshConcertsCommand = new Command(async() => { await ExecuteLoadConcertsCommand(); pageNumber = 1; ConcertTreshold = 4; IsRefreshing = false; }); MessagingCenter.Subscribe <ConcertsPage, TextChangedEventArgs>(this, "FilterConcerts", (obj, e) => { var filterText = e.NewTextValue; var filtered = Concerts.Where(item => item.Title.ToLower().Contains(filterText.ToLower())); if (filtered != null) { FilteredConcerts = new ObservableCollection <Concert>(); FilteredConcerts.AddRange(filtered); } else { FilteredConcerts = new ObservableCollection <Concert>(); } }); }
public ActionResult Index() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ConcertService(userId); var model = service.GetNotes(); return(View(model)); }
public async void CanGetConcert() { using (var setup = new SQLiteInMemorySetup()) { using (var context = new ConcertManagerContext(setup.ContextOptions)) { context.Database.EnsureCreated(); } using (var context = new ConcertManagerContext(setup.ContextOptions)) { var service = new ConcertService(context); Concert concert = await service.GetConcertAsync(1); Assert.Equal(new DateTime(2019, 03, 04), concert.Date); } } }
public async void CanDeleteConcert() { using (var setup = new SQLiteInMemorySetup()) { using (var context = new ConcertManagerContext(setup.ContextOptions)) { context.Database.EnsureCreated(); } using (var context = new ConcertManagerContext(setup.ContextOptions)) { var service = new ConcertService(context); await service.DeleteConcertAsync(7); } using (var context = new ConcertManagerContext(setup.ContextOptions)) { Assert.Equal(6, context.Concerts.Count()); } } }
public async void CanUpdateConcert() { using (var setup = new SQLiteInMemorySetup()) { using (var context = new ConcertManagerContext(setup.ContextOptions)) { context.Database.EnsureCreated(); } using (var context = new ConcertManagerContext(setup.ContextOptions)) { var service = new ConcertService(context); await service.UpdateConcertAsync(1, new Concert { Date = new DateTime(2030, 03, 03), TicketsAvailable = true, Venue = context.Venues.First() }, Enumerable.Empty <Band>().ToList()); } using (var context = new ConcertManagerContext(setup.ContextOptions)) { Assert.Equal(7, context.Concerts.Count()); Assert.Equal(new DateTime(2030, 03, 03), context.Concerts.Find(1).Date); } } }
public async void CanGetConcerts() { using (var setup = new SQLiteInMemorySetup()) { using (var context = new ConcertManagerContext(setup.ContextOptions)) { context.Database.EnsureCreated(); } using (var context = new ConcertManagerContext(setup.ContextOptions)) { var service = new ConcertService(context); List <Concert> concerts = (await service.GetConcertsAsync()).ToList(); Assert.Equal(7, concerts.Count); Assert.Equal(new DateTime(2019, 03, 04), concerts[0].Date); Assert.Equal(new DateTime(2020, 12, 07), concerts[1].Date); Assert.Equal(new DateTime(2020, 05, 15), concerts[2].Date); Assert.Equal(new DateTime(2020, 02, 27), concerts[3].Date); Assert.Equal(new DateTime(2021, 03, 01), concerts[4].Date); Assert.Equal(new DateTime(2020, 08, 30), concerts[5].Date); Assert.Equal(new DateTime(2021, 01, 18), concerts[6].Date); } } }
public ListEventViewModel(ConcertService service) { concertService = service; Concerts = new ObservableCollection <ConcertDTO>(concertService.GetAll()); }
public ConcertController(ConcertService concertService) { _concertService = concertService; }