public async Task <IActionResult> Index(string currency = "USD") { if (false) { //TODO //remove at the very end var coins = await _service.GetCryptocurrenciesAsync(); await _dbService.AddCryptocurrenciesToDatabaseAsync(coins.Select(x => new Cryptocurrency { Symbol = x.Key, Name = x.Value }).ToList()); } if (_userId == null) { return(RedirectToAction("Index", "Summary")); } else { var data = new SubscriptionsViewModel(); List <Cryptocurrency> userCurrencies = (await _dbService.GetWatchlist(_userId)).ToList(); data.WatchedCryptocurrencies = new List <SubscribedCryptoViewModel>(); foreach (var userCurrency in userCurrencies) { data.WatchedCryptocurrencies.Add(new SubscribedCryptoViewModel(userCurrency, _service.GetCryptocurrencyInfoAsync(userCurrency.Symbol, currency).Result)); } data.Cryptocurrencies = _service.GetCryptocurrenciesAsync().Result; data.Currencies = _service.GetCurrencies(); return(View(data)); } }
public async Task <IHttpActionResult> Post(SubscriptionsViewModel subscriptionsVM) { var activationProcessor = new ActivationProcessor(); await activationProcessor.SaveEnrolledSubscriptions(subscriptionsVM); return(this.Ok()); }
private async void OnMoviesWatchedExecute() { if (SelectedMember != null) { SubscriptionsViewModel.Clear(); SubscriptionViewModel subscriptionViewModel; foreach (var subscription in SelectedMember.Subscriptions) { subscriptionViewModel = new SubscriptionViewModel(); Movie movie = null; try { movie = await _movieRepository.GetByIdAsync(subscription.MovieId); } //TODO: A second operation started on this context before a previous operation completed. // This is usually caused by different threads using the same instance of DbContext. catch (Exception) { } // TODO:Bug - add double watch date withou movie if (movie == null) { continue; } subscriptionViewModel.Id = subscription.Id; subscriptionViewModel.Movie = movie; subscriptionViewModel.Member = SelectedMember.Model; subscriptionViewModel.WatchedDate = subscription.WatchedDate; subscriptionViewModel.SelectedMovieDetailsCommand = new DelegateCommand <string>(OnSelectedMovieDetailsExecute); SubscriptionsViewModel.Add(subscriptionViewModel); } } }
public SubscriptionsView() { InitializeComponent(); _viewModel = new SubscriptionsViewModel(); this.DataContext = _viewModel; }
public Subscriptions(TeamExplorerIntergator te) { InitializeComponent(); vm = new SubscriptionsViewModel(); vm.Load(te); this.DataContext = vm; }
protected override void HandleOnNavigatedTo(NavigationEventArgs e) { base.HandleOnNavigatedTo(e); if (this._isInitialized) { return; } this._viewModel = new SubscriptionsViewModel(long.Parse(this.NavigationContext.QueryString["UserId"])); this._viewModel.LoadData(false, (Action <bool>)null); this.DataContext = (object)this._viewModel; this._isInitialized = true; }
public async Task <ActionResult> Search(string name) { var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } _appDbContext.Entry(user).Collection(x => x.Subs).Load(); var model = new SubscriptionsViewModel { SubscriptionWrapperList = new List <SubscriptionWrapper>(), CurrentUser = user, StatusMessage = StatusMessage }; // Fill in the subscription wrapper list with all users foreach (ApplicationUser someUser in _appDbContext.Users) { bool isSubcribed = false; foreach (Subscription cuSub in model.CurrentUser.Subs) { if (cuSub.SubscribingToUserID == someUser.Id) { // Current user is subscribed to this user isSubcribed = true; break; } } string nameOne = someUser.FullName.ToUpper(); string nameTwo = name.ToUpper(); if (nameOne.CompareTo(nameTwo) == 0) { if (user.Id != someUser.Id) { model.SubscriptionWrapperList.Add( new SubscriptionWrapper { SubscribedUser = someUser, SubscribedUserID = someUser.Id, IsSubscribed = isSubcribed } ); } } } return(PartialView("~/Views/Home/Search.cshtml", model)); }
public async Task <IActionResult> Subscriptions() { ViewData["Message"] = "Your Subscriptions."; var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } _appDbContext.Entry(user).Collection(x => x.Subs).Load(); var model = new SubscriptionsViewModel { SubscriptionWrapperList = new List <SubscriptionWrapper>(), CurrentUser = user, StatusMessage = StatusMessage }; // Fill in the subscription wrapper list with all users foreach (ApplicationUser someUser in _appDbContext.Users) { bool isSubcribed = false; foreach (Subscription cuSub in model.CurrentUser.Subs) { if (cuSub.SubscribingToUserID == someUser.Id) { // Current user is subscribed to this user isSubcribed = true; break; } } if (user.Id != someUser.Id) { model.SubscriptionWrapperList.Add( new SubscriptionWrapper { SubscribedUser = someUser, SubscribedUserID = someUser.Id, IsSubscribed = isSubcribed } ); } } return(View(model)); }
public ActionResult Subscriptions() { var model = new SubscriptionsViewModel(); // Get the calendars we are subscribed to var calendars = Exigo.GetCustomerCalendarSubscriptions(Identity.Current.CustomerID); // Get the customers for each of the calendar subscriptions var customerIDs = calendars.Select(c => c.CustomerID).Distinct().ToList(); var apiCustomers = Exigo.OData().Customers .Where(customerIDs.ToOrExpression <Common.Api.ExigoOData.Customer, int>("CustomerID")) .Select(c => new Common.Api.ExigoOData.Customer() { CustomerID = c.CustomerID, FirstName = c.FirstName, LastName = c.LastName }) .ToList(); // Pair the data together to create our models var customers = new List <CalendarSubscriptionCustomer>(); foreach (var apiCustomer in apiCustomers) { // Create the special customer first var customer = new CalendarSubscriptionCustomer() { CustomerID = apiCustomer.CustomerID, FirstName = apiCustomer.FirstName, LastName = apiCustomer.LastName }; // Add their calendars customer.Calendars = calendars.Where(c => c.CustomerID == customer.CustomerID).ToList(); // Add our model to the collection model.CalendarSubscriptionCustomers.Add(customer); } return(View(model)); }
public IActionResult RemoveSubscription(SubscriptionsViewModel subscription) { _subscriptionsService.RemoveSubscription(subscription.Id); DateTime dateTime = new DateTime(); if (!string.IsNullOrEmpty(subscription.MonthStr)) { DateTime.TryParse(subscription.MonthStr, out dateTime); } return(RedirectToAction(nameof(Index), new { selectedSchoolId = subscription.SelectedSchoolId, selectedCourseId = subscription.SelectedCourseId, MonthStr = dateTime, searchName = subscription.SearchName, showFilter = subscription.ShowFilter, })); }
public IActionResult Subscriptions(string profileId) { ViewBag.SubsectionPages = _subsectionPages; ViewBag.ActiveSubpage = "User's Subscriptions"; var usr = _db.NeobooruUsers .Include(usr => usr.Subscriptions) .ThenInclude(subs => subs.Artist) .FirstOrDefault(a => a.Id.Equals(profileId)); if (usr == null) { Redirect("/"); } Func <ArtistSubscription, ArtistThumbnailViewModel> subToThumbnail = (s) => { int likes = _db.ArtLikes.Include(s => s.LikedArt.Author) .Count(l => l.LikedArt.Author.Id.ToString().Equals(s.Artist.Id.ToString())); return(new ArtistThumbnailViewModel(s.Artist, s.Artist.Arts.Count(), s.Artist.Subscriptions.Count(), likes)); }; List <ArtistThumbnailViewModel> thumbnails = _db.ArtistSubscriptions .Include(s => s.Artist) .ThenInclude(s => s.Arts) .Include(s => s.Artist.Subscriptions) .Where(s => s.Subscriber.Id.Equals(profileId)) .OrderByDescending(s => s.SubscribedOn) .Select(subToThumbnail).ToList(); SubscriptionsViewModel svm = new SubscriptionsViewModel() { Username = usr.UserName, ProfileId = profileId, PfpUrl = usr.PfpUrl, BackgroundUrl = usr.BgUrl, Description = usr.ProfileDescription, Thumbnails = thumbnails }; return(View(svm)); }
private async void OnMembersWatchedExecute() { if (SelectedMovie != null) { SubscriptionsViewModel.Clear(); SubscriptionViewModel subscriptionViewModel; foreach (var subscription in SelectedMovie.Subscriptions) { subscriptionViewModel = new SubscriptionViewModel(); var member = await _memberRepository.GetByIdAsync(subscription.MemberId); subscriptionViewModel.Id = subscription.Id; subscriptionViewModel.Movie = SelectedMovie.Model; subscriptionViewModel.Member = member; subscriptionViewModel.WatchedDate = subscription.WatchedDate; subscriptionViewModel.SelectedMemberDetailsCommand = new DelegateCommand <string>(OnSelectedMemberDetailsExecute); SubscriptionsViewModel.Add(subscriptionViewModel); } } }
public async Task <IActionResult> Subscriptions(string id) { var user = await _userManager.FindByNameAsync(id); if (user == null) { return(NotFound()); } var mySubs = _dbContext .Subscriptions .Include(t => t.Course) .Where(t => t.UserId == user.Id); var model = new SubscriptionsViewModel { MySubscriptions = mySubs }; await model.Restore(user, 2, _dbContext, await GetCurrentUserAsync()); return(View(model)); }
public ActionResult Subscriptions() { var model = new SubscriptionsViewModel(); // Get the Calendar Subscriptions for the provided Customer ID var calendars = Exigo.GetCustomerCalendarSubscriptions(Identity.Current.CustomerID); // Get the CustomerIDs for each of the Calendar Subscriptions var customerIDs = calendars.Select(c => c.CustomerID).Distinct().ToList(); var customerCalendarSubscription = new List <CalendarSubscriptionCustomer>(); using (var context = Exigo.Sql()) { customerCalendarSubscription = context.Query <CalendarSubscriptionCustomer>(@" SELECT c.CustomerID ,c.FirstName ,c.LastName FROM Customers c WHERE c.CustomerID IN @customerids", new { customerids = customerIDs }).ToList(); //Apply the correct calendars to the customers foreach (var customer in customerCalendarSubscription) { customer.Calendars = calendars.Where(c => c.CustomerID == customer.CustomerID).ToList(); } model.CustomerCalendarSubscriptions = customerCalendarSubscription; } return(View(model)); }
public ActionResult Subscriptions(string taxonId) { if (taxonId.IsNull()) { taxonId = this.TaxonIdentifier.Id.ToString(); } TaxonSearchResult searchResult = this.TaxonSearchManager.GetTaxon(taxonId); if (searchResult.NumberOfMatches != 1) { return(RedirectToSearch(taxonId)); } TaxonIdentifier = TaxonIdTuple.Create(taxonId, searchResult.Taxon.Id); ITaxon taxon = searchResult.Taxon; ViewBag.Taxon = taxon; SubscriptionViewManager subscriptionViewManager = new SubscriptionViewManager(GetCurrentUser()); SubscriptionsViewModel model = subscriptionViewManager.CreateSubscriptionsViewModel(taxon); return(View(model)); }
public IActionResult Index(string selectedSchoolId, string selectedCourseId, string MonthStr, string searchName, bool showFilter) { DateTime dateTime = new DateTime(); if (!string.IsNullOrEmpty(MonthStr)) { DateTime.TryParse(MonthStr, out dateTime); } IEnumerable <School> schools = _schoolService.GetAllSchools(); IEnumerable <Subscription> subscriptions = _subscriptionsService .GetFilteredSubscriptions(selectedSchoolId, selectedCourseId, dateTime, searchName); SubscriptionsViewModel model = new SubscriptionsViewModel { _Subscriptions = subscriptions, Schools = schools, SelectedSchoolId = selectedSchoolId, SelectedCourseId = selectedCourseId, Month = dateTime, SearchName = searchName, ShowFilter = showFilter, }; return(View(model)); }
public MainWindow() { InitializeComponent(); DataContext = new SubscriptionsViewModel(); }
public SubscriptionsPage(SubscriptionsViewModel vm) { InitializeComponent(); BindingContext = vm; }
public async Task <ActionResult> UpdateSubscriber(bool check, SubscriptionsViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } _appDbContext.Entry(user).Collection(x => x.Subs).Load(); _appDbContext.Entry(user).Collection(x => x.Achivements).Load(); List <GlobalAchievement> globalAchievementList = _appDbContext.GlobalAchievements.ToList(); for (int i = 0; i < model.SubscriptionWrapperList.Count; i++) { SubscriptionWrapper aw = model.SubscriptionWrapperList[i]; Subscription targetSubscription = user.Subs.Where(x => x.SubscribingToUserID == aw.SubscribedUserID).SingleOrDefault(); // Only update if there's a change if (targetSubscription == null && check == true) { Subscription toSub = new Subscription { SubscribingUserID = user.Id, SubscribingToUserID = aw.SubscribedUserID }; user.Subs.Add(toSub); } else if (targetSubscription != null && check == false) { user.Subs.Remove(user.Subs.Where(x => x.SubscribingToUserID == aw.SubscribedUserID).SingleOrDefault()); } } if (user.Subs.Count() >= 2) { user.AddUserAchievement(globalAchievementList, "Subscribed to 1 person!"); } if (user.Subs.Count() >= 5) { user.AddUserAchievement(globalAchievementList, "Subscribed to 5 people!"); } if (user.Subs.Count() >= 10) { user.AddUserAchievement(globalAchievementList, "Subscribed to 10 people!"); } if (user.Subs.Count() >= 20) { user.AddUserAchievement(globalAchievementList, "Subscribed to 20 people!"); } var setResult = await _userManager.UpdateAsync(user); if (!setResult.Succeeded) { throw new ApplicationException($"Unexpected error occurred setting subscriptions for user with ID '{user.Id}'."); } StatusMessage = "Your subscriptions have been updated"; return(RedirectToAction(nameof(Subscriptions))); }
public SubscriptionsPage() { InitializeComponent(); BindingContext = _viewModel = new SubscriptionsViewModel(); }
public SubscriptionsControl() { InitializeComponent(); DataContext = new SubscriptionsViewModel(); }
public SubscriptionsView() { InitializeComponent(); vm = Resources["vm"] as SubscriptionsViewModel; }