public IHttpActionResult Backend_Detail_New() { BackendTournamentViewModel viewmodel = new BackendTournamentViewModel(); TournamentGameDataController gameDataCtrl = new TournamentGameDataController(); EventDataController eventDataCtrl = new EventDataController(); try { viewmodel.EventOptions = eventDataCtrl.GetItems().ToList().ConvertAll(x => { return(new BackendEventViewModelItem().FromModel(x)); }).OrderByDescending(x => x.ID).ToList(); viewmodel.GameOptions = gameDataCtrl.GetItems().ToList().ConvertAll(x => { return(new BackendGameViewModelItem().FromModel(x)); }).OrderBy(x => x.Name).ToList(); viewmodel.Data.Event = viewmodel.EventOptions[0]; viewmodel.Data.Start = viewmodel.Data.Event.Start; } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel)); }
public IHttpActionResult GetGallery() { GalleryListModel viewmodel = new GalleryListModel(); EventDataController dataCtrl = new EventDataController(); var ev = dataCtrl.GetItems().OrderByDescending(x => x.Start); foreach (var _event in ev) { Int32 count; try { count = GalleryDataController.Count(_event.ID); } catch (DirectoryNotFoundException) { continue; } var eid = _event.ID; var thumb = GalleryDataController.GetGalleryThumbnail(_event.ID)?.ImageUrl; if (thumb == null || count == 0) { continue; } viewmodel.Data.Add(new GalleryViewModelListItem().FromModel(_event, count, thumb)); } return(Ok(viewmodel)); }
public IHttpActionResult Backend_Detail_Update(Int32 id, BackendTournamentViewModelItem request) { BackendTournamentViewModel viewmodel = new BackendTournamentViewModel(); TournamentDataController dataCtrl = new TournamentDataController(); TournamentGameDataController gameDataCtrl = new TournamentGameDataController(); EventDataController eventDataCtrl = new EventDataController(); try { viewmodel.EventOptions = eventDataCtrl.GetItems().ToList().ConvertAll(x => { return(new BackendEventViewModelItem().FromModel(x)); }).OrderByDescending(x => x.ID).ToList(); viewmodel.GameOptions = gameDataCtrl.GetItems().ToList().ConvertAll(x => { return(new BackendGameViewModelItem().FromModel(x)); }).OrderBy(x => x.Name).ToList(); var data = dataCtrl.Update(request.ToModel()); viewmodel.Data.FromModel(data); } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel, "Speichern erfolgreich.")); }
public IHttpActionResult Backend_Detail(Int32 id) { BackendCateringViewModel viewmodel = new BackendCateringViewModel(); CateringOrderDataController dataCtrl = new CateringOrderDataController(); EventDataController eventDataCtrl = new EventDataController(); UserDataController userDataCtrl = new UserDataController(); try { viewmodel.EventOptions = eventDataCtrl.GetItems().ToList().ConvertAll(x => { return(new BackendEventViewModelItem().FromModel(x)); }).OrderByDescending(x => x.ID).ToList(); viewmodel.UserOptions = userDataCtrl.GetItems().OrderBy(x => x.FirstName).ToList().ConvertAll(x => { return(new BackendUserViewModelItem().FromModel(x)); }); viewmodel.Data.FromModel(dataCtrl.GetItem(id)); } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel)); }
public IHttpActionResult Get() { FbNewsListViewModel viewmodel = new FbNewsListViewModel(); EventDataController dataCtrl = new EventDataController(); var nextEvent = dataCtrl.GetItems().OrderByDescending(x => x.Start).FirstOrDefault(x => x.Start > DateTime.Now); if (nextEvent != null) { viewmodel.NextEvent = new EventViewModelItem().FromModel(nextEvent); } viewmodel.Data = NewsDataController.GetItems().data; return(Ok(viewmodel)); }
public IHttpActionResult Get() { CateringListViewModel viewmodel = new CateringListViewModel(); CateringProductDataController dataCtrl = new CateringProductDataController(); SeatDataController seatDataCtrl = new SeatDataController(); EventDataController eventDataCtrl = new EventDataController(); try { var e = eventDataCtrl.GetItems().FirstOrDefault(x => x.Start <= DateTime.Now && x.End >= DateTime.Now); if (e == null) { return(Warning(viewmodel, "Keine passende Veranstaltung gefunden.")); } else if (!e.IsActiveCatering) { return(Warning(viewmodel, "Das Catering ist derzeit deaktiviert.")); } foreach (var model in dataCtrl.GetItems().Where(x => x.IsActive)) { ProductViewModelItem item = new ProductViewModelItem(); item.FromModel(model); viewmodel.Data.Add(item); } int eventID = e.ID; foreach (var model in seatDataCtrl.GetCurrentUserSeats(eventID)) { CateringSeat item = new CateringSeat(); item.FromModel(model); viewmodel.Seats.Add(item); } } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel)); }
public IHttpActionResult Backend_FilterList(BackendCateringListArgs args) { BackendCateringListViewModel viewmodel = new BackendCateringListViewModel(); EventDataController eventDataCtrl = new EventDataController(); CateringOrderDataController orderDataCtrl = new CateringOrderDataController(); CateringProductDataController cateringDataCtrl = new CateringProductDataController(); UserDataController userDataCtrl = new UserDataController(); try { var events = eventDataCtrl.GetItems().OrderByDescending(x => x.ID).ToList(); viewmodel.Filter.EventOptions = events.ConvertAll(x => { return(new BackendCateringFilter.CateringFilterEvent() { ID = x.ID, Name = $"{x.EventType.Name} Vol.{x.Volume}" }); }); var products = cateringDataCtrl.GetItems().ToList(); viewmodel.ProductOptions = products.ConvertAll(x => { return(new BackendCateringProductItem().FromModel(x)); }); viewmodel.Filter.Name = args.Filter.Name; viewmodel.Filter.SeatNumber = args.Filter.SeatNumber; viewmodel.Filter.EventSelected = args.Filter.EventSelected; viewmodel.Filter.StatusSelected = args.Filter.StatusSelected; viewmodel.Pagination = args.Pagination; Int32 TotalItemsCount = 0; viewmodel.FromModel(orderDataCtrl.FilterList(args, out TotalItemsCount)); viewmodel.Pagination.TotalItemsCount = TotalItemsCount; } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel)); }
public IHttpActionResult Backend_FilterList(ListArgsRequest <BackendSeatingFilter> request) { BackendSeatingListViewModel viewmodel = new BackendSeatingListViewModel(); SeatDataController dataCtrl = new SeatDataController(); EventDataController eventDataCtrl = new EventDataController(); UserDataController userDataCtrl = new UserDataController(); var events = eventDataCtrl.GetItems().OrderByDescending(x => x.Start).ToList(); var users = userDataCtrl.GetItems().OrderBy(x => x.FirstName).ToList(); var eID = request.Filter.EventSelected.ID; var seats = dataCtrl.FilterList(request); viewmodel.Filter.EventSelected = request.Filter.EventSelected; viewmodel.Filter.EventOptions = events.ConvertAll(x => { return(new SeatingFilterEvent() { ID = x.ID, Name = $"{x.EventType.Name} Vol.{x.Volume}" }); }); for (int i = 1; i <= Properties.Settings.Default.SeatAmount; i++) { BackendSeatingViewModelItem item = new BackendSeatingViewModelItem(); Seat model = seats.FirstOrDefault(x => x.SeatNumber == i); if (model == null) { model = new Seat() { SeatNumber = i, State = 0, Event = events[0] } } ; item.FromModel(model); viewmodel.Data.Add(item); } return(Ok(viewmodel)); }
public IHttpActionResult Get() { EventListViewModel viewmodel = new EventListViewModel(); EventDataController dataCtrl = new EventDataController(); try { var events = dataCtrl.GetItems().Where(x => x.End >= DateTime.Now).OrderBy(y => y.Start); foreach (var e in events) { viewmodel.Data.Add(new EventViewModelItem().FromModel(e)); } } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel)); }
public IHttpActionResult Backend_FilterList(BackendTournamentListArgs args) { BackendTournamentListViewModel viewmodel = new BackendTournamentListViewModel(); TournamentDataController dataCtrl = new TournamentDataController(); TournamentGameDataController gameDataCtrl = new TournamentGameDataController(); EventDataController eventDataCtrl = new EventDataController(); try { viewmodel.Filter.GameSelected = args.Filter.GameSelected; viewmodel.Filter.EventSelected = args.Filter.EventSelected; viewmodel.Filter.GameOptions = gameDataCtrl.GetItems().OrderBy(x => x.Name).ToList().ConvertAll(x => { return(new BackendTournamentFilter.TournamentFilterGame() { ID = x.ID, Name = x.Name }); }); viewmodel.Filter.EventOptions = eventDataCtrl.GetItems().ToList().ConvertAll(x => { return(new BackendTournamentFilter.TournamentFilterEvent() { ID = x.ID, Name = x.EventType.Name + " Vol. " + x.Volume.ToString() }); }).OrderByDescending(x => x.ID).ToList(); viewmodel.Pagination = args.Pagination; Int32 TotalItemsCount = 0; viewmodel.Data.FromModel(dataCtrl.FilterList(args, out TotalItemsCount)); viewmodel.Pagination.TotalItemsCount = TotalItemsCount; } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel)); }
public static AccountReservationViewModelItem FromModel(this AccountReservationViewModelItem viewmodel, User model) { EventDataController eventDataCtrl = new EventDataController(); SeatTransferLogDataController transferDataCtrl = new SeatTransferLogDataController(); viewmodel.Name = $"{model.FirstName} {model.LastName}"; viewmodel.Image = Properties.Settings.Default.imageAbsolutePath + "team/no_image.png"; // TODO viewmodel.Events = eventDataCtrl.GetItems().Where(x => x.End > DateTime.Now).ToList().ConvertAll(x => { var vm = new AccountReservationEventViewModelItem(); vm.FromModel(x, model); return(vm); }); viewmodel.BankAccountData.FromProperties(); viewmodel.TransferLog.Add(new AccountReservationSeatTransferLogViewModelItem() { Date = DateTime.Now.AddDays(-3), Text = "asdfghjkl" }); viewmodel.TransferLog.Add(new AccountReservationSeatTransferLogViewModelItem() { Date = DateTime.Now.AddDays(-2), Text = "asdfghjkl" }); viewmodel.TransferLog.Add(new AccountReservationSeatTransferLogViewModelItem() { Date = DateTime.Now.AddDays(-1), Text = "asdfghjkl" }); viewmodel.TransferLog.AddRange(transferDataCtrl.GetItems().Where(x => x.DestinationUser.ID == model.ID).ToList().ConvertAll(x => { return(SendTicketString(x)); })); viewmodel.TransferLog.AddRange(transferDataCtrl.GetItems().Where(x => x.SourceUser.ID == model.ID).ToList().ConvertAll(x => { return(RecivedTicketString(x)); })); viewmodel.TransferLog = viewmodel.TransferLog.OrderByDescending(x => x.Date).ToList(); return(viewmodel); }
public IHttpActionResult Insert(OrderRequest request) { OrderRequest viewmodel = request; CateringOrderDataController dataCtrl = new CateringOrderDataController(); EventDataController eventDataCtrl = new EventDataController(); try { var e = eventDataCtrl.GetItems().FirstOrDefault(x => x.Start <= DateTime.Now && x.End >= DateTime.Now); if (e == null) { return(Warning(viewmodel, "Die Bestellung konnte keiner Veranstaltung zugeordnet werden.")); } int eventID = e.ID; dataCtrl.Insert(request.ToModel(eventID)); } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel, "Bestellung ist eingegangen.")); }
public IHttpActionResult Frontend() { NavigationViewModel viewmodel = new NavigationViewModel(); EventDataController dataCtrl = new EventDataController(); SeatDataController seatDataCtrl = new SeatDataController(); PartnerDisplayRelationDataController displayDataCtrl = new PartnerDisplayRelationDataController(); var events = dataCtrl.GetItems().ToList(); var nextEvent = events.OrderByDescending(x => x.Start).First(); if (events.OrderByDescending(x => x.Start).FirstOrDefault(x => x.End > DateTime.Now) != null) { nextEvent = events.OrderByDescending(x => x.Start).FirstOrDefault(x => x.End > DateTime.Now); } var partner = displayDataCtrl.GetItems() .Where(x => x.Partner.IsActive) .OrderByDescending(x => x.Partner.PartnerPackID) .ThenBy(x => x.Partner.Position); #region NavigationTop viewmodel.Data.NavigationTop.Add(new NavItem() { Text = "News", State = "news.all", StateCompare = "news" }); viewmodel.Data.NavigationTop.Add(new NavItem() { Text = "Events", State = "event.all", StateCompare = "event" }); viewmodel.Data.NavigationTop.Add(new NavItem() { Text = "Galerie", State = "gallery.all", StateCompare = "gallery" }); viewmodel.Data.NavigationTop.Add(new NavItem() { Text = "Turniere", State = "event.tournaments.all({id: " + nextEvent.ID + "})", StateCompare = "event.tournaments" }); viewmodel.Data.NavigationTop.Add(new NavItem() { Text = "Sitzplan", State = "event.seating({id: " + nextEvent.ID + "})", StateCompare = "event.seating" }); viewmodel.Data.NavigationTop.Add(new NavItem() { Text = "Sponsoren", State = "partner", StateCompare = "partner" }); #endregion #region NavigationUser if (UserHelper.Authenticated) { if (UserHelper.CurrentUserRole == UserRole.Admin || UserHelper.CurrentUserRole == UserRole.Team) { viewmodel.Data.NavigationUser.Add(new NavItem() { Text = "<i class='fas fa-user-secret'></i>", State = "admin.dashboard", StateCompare = "admin.dashboard", Tooltip = "Adminbereich" }); } viewmodel.Data.NavigationUser.Add(new NavItem() { Text = "<i class='fas fa-utensils'></i>", State = "catering", StateCompare = "catering", Tooltip = "Catering" }); //viewmodel.Data.NavigationUser.Add(new NavItem() //{ // Text = "<i class='fas fa-comments'></i>", // State = "profile.overview", // StateCompare = "profile", // Tooltip = "Chat" //}); viewmodel.Data.NavigationUser.Add(new NavItem() { Text = "<i class='fas fa-user-circle'></i>", State = "profile.overview", StateCompare = "profile", Tooltip = UserHelper.CurrentUserName }); viewmodel.Data.NavigationUser.Add(new NavItem() { Text = "<i class='fas fa-sign-out'></>", State = "logout", StateCompare = "logout", Tooltip = "Ausloggen" }); } else { viewmodel.Data.NavigationUser.Add(new NavItem() { Text = "<i class='fas fa-user-plus'></i>", State = "register", StateCompare = "register", Tooltip = "Registrieren" }); viewmodel.Data.NavigationUser.Add(new NavItem() { Text = "<i class='fas fa-sign-in'></i>", State = "login", StateCompare = "login", Tooltip = "Einloggen" }); } #endregion #region NavigationAside viewmodel.Data.NavigationAside.Add(new NavItem() { Text = "Informationen", State = "event.details({id: " + nextEvent.ID + "})" }); viewmodel.Data.NavigationAside.Add(new NavItem() { Text = "Sitzplan", State = "event.seating({id: " + nextEvent.ID + "})" }); viewmodel.Data.NavigationAside.Add(new NavItem() { Text = "Jugendschutz", State = "jugendschutz" }); viewmodel.Data.NavigationAside.Add(new NavItem() { Text = "Teilnahmebedingungen", State = "teilnahmebedingungen" }); viewmodel.Data.NavigationAside.Add(new NavItem() { Text = "Kontakt", State = "contact" }); #endregion #region EventsAside foreach (var e in events.Where(x => x.End > DateTime.Now).OrderByDescending(x => x.Start)) { var seats = seatDataCtrl.GetItems().Where(x => x.EventID == e.ID); Int32 seatsCount = Properties.Settings.Default.SeatAmount - seats.Count(x => x.State == -1); Int32 flagged = seats.Count(x => x.State == 1); Int32 reserved = seats.Count(x => x.State >= 2); Int32 free = seatsCount - flagged - reserved; viewmodel.Data.EventsAside.Add(new EventItem() { ID = e.ID, Title = $"{e.EventType.Name} Vol.{e.Volume}", Start = e.Start, End = e.End, PublicAccess = !e.IsPrivate, Seating = new data.ViewModel.Event.EventViewModelItem.SeatingReservation() { SeatsCount = seatsCount, Flagged = flagged, Reserved = reserved, Free = free } }); } #endregion #region PartnerTop foreach (var p in partner.Where(x => x.PartnerDisplay.Name == "Header")) { viewmodel.Data.PartnerTop.Add(new PartnerItem() { Name = p.Partner.Name, Link = p.Partner.Link, ImagePassive = Properties.Settings.Default.imageAbsolutePath + p.Partner.ImagePassive, ImageOriginal = Properties.Settings.Default.imageAbsolutePath + p.Partner.ImageOriginal }); } #endregion #region NavigationBottom foreach (var p in partner.Where(x => x.PartnerDisplay.Name == "Footer")) { viewmodel.Data.NavigationBottom.Add(new LinkItem() { Text = p.Partner.Name, Link = p.Partner.Link }); } #endregion return(Ok(viewmodel)); }