public MainWindowViewModel(IWindowManager windowManager, string connectionString) { _windowManager = windowManager; Login = connectionString.Split(';').ToList().Where(n => n.IndexOf("uid=") != -1).ToList()[0]; _signInTime = DateTime.Now.ToUniversalTime().ToLongDateString() + DateTime.Now.ToShortTimeString(); NotifyOfPropertyChange(() => DateTimeSignIn); using (var context = new DAL.Repositories.EFUnitOfWork(connectionString)) { //var item = (Attachments)context.Attachments.Find(o => o.Content == "записывайся блять").FirstOrDefault(); //if (item != null) //{ // item.Content = "пяздец"; // context.Attachments.Update(item); // context.Save(); //} //CarouselItems.Clear(); context.Attachments.GetAll().ToList().ForEach(n => CarouselItems.Add(n.Content)); SelectedItem = CarouselItems.First(); //var item = new DAL.Models.Attachments() { AttachTypeId = 2, Content = "записывайся блять", CreateDate = DateTime.UtcNow.Date}; //context.Attachments.Create(item); } }
public async Task LoadFeaturedAsync() { try { WeakReferenceMessenger.Default.Send(new PageLoadingMessage(true)); var featured = await FSApi.GetHomePageFeaturedAsync(Windows.ApplicationModel.Package.Current.Id.Version.ToVersion()); CarouselItems.CollectionChanged += CarouselItems_CollectionChanged; CarouselItems.Clear(); for (int i = 0; i < featured.Carousel.Count; i++) { try { Urn packageUrn = Urn.Parse(featured.Carousel[i]); var package = await PackageService.GetPackageAsync(packageUrn); CarouselItems.Add(new PackageViewModel(package)); if (i == 0) { SelectedCarouselItemIndex = i; } } catch (System.Exception ex) { var logger = Ioc.Default.GetRequiredService <LoggerService>(); logger.Warn(ex, ex.Message); } } CarouselItems.CollectionChanged -= CarouselItems_CollectionChanged; // Load featured packages from other sources FeaturedPackages = new ObservableCollection <HandlerPackageListPair>(); await foreach (HandlerPackageListPair pair in PackageService.GetFeaturedPackagesAsync()) { FeaturedPackages.Add(pair); } } catch (Flurl.Http.FlurlHttpException ex) { NavService.ShowHttpErrorPage(ex); } catch (System.Exception ex) { var logger = Ioc.Default.GetRequiredService <LoggerService>(); logger.Warn(ex, ex.Message); } WeakReferenceMessenger.Default.Send(new PageLoadingMessage(false)); }
public async Task LoadFeaturedAsync() { var culture = CultureInfo.CurrentUICulture; var region = new RegionInfo(culture.LCID); var featured = await FSApi.GetHomePageFeaturedAsync(); CarouselItems.Clear(); for (int i = 0; i < featured.Carousel.Count; i++) { string productId = featured.Carousel[i]; var product = (await StorefrontApi.GetProduct(productId, region.TwoLetterISORegionName, culture.Name)) .Convert <ProductDetails>().Payload; CarouselItems.Add(new ProductDetailsViewModel(product)); if (i == 0 || (i == 1 && featured.Carousel.Count >= 3)) { SelectedCarouselItemIndex = i; } } }