static void Main(string[] args) { CatalogView catalog1 = new CatalogView(new DrawThreeVehiclesByLine()); catalog1.Draw(); CatalogView catalog2 = new CatalogView(new DrawVehicleByLine()); catalog2.Draw(); Console.ReadKey(); }
public CatalogViewModel(ProductRepository productRepository, GroupRepository groupRepository, SubGroupRepository subGroupRepository, CartRepository cartRepository, AdminRepository adminRepository, PersonRepository personRepository, CatalogView catalogView, MainViewModel mainViewModel) { _productRepository = productRepository; _groupRepository = groupRepository; _subGroupRepository = subGroupRepository; _cartRepository = cartRepository; _adminRepository = adminRepository; _personRepository = personRepository; _catalogView = catalogView; _products = new ObservableCollection <Product>(_productRepository.GetWithInclude(x => x.PictureID, x => x.Discount, x => x.SubGroup, x => x.Carts)); _mainViewModel = mainViewModel; }
public ActionResult Index(int?id) { CatalogView vm = new CatalogView(); if (id.HasValue) { vm.main = __db.Catalog.FirstOrDefault(f => f.Id == id); } else { vm.main = __db.Catalog.FirstOrDefault(); } vm.List = __db.Catalog.ToList(); return(View(vm)); }
public ActionResult CreateCatalog(CatalogView catalog) { try { var article = new Article() { Category = Category.Catalog, Name = catalog.Name, Order = catalog.Order, ParentId = catalog.ParentId }; article.Create(); return(this.Json(new ActionResultStatus(), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(this.Json(new ActionResultStatus(ex), JsonRequestBehavior.AllowGet)); } }
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e) { CatalogView.BeginRefresh(); if (string.IsNullOrWhiteSpace(e.NewTextValue)) { CatalogView.ItemsSource = Catalog; } else { CatalogView.ItemsSource = Catalog.Where( s => s.Title.IndexOf(e.NewTextValue, StringComparison.OrdinalIgnoreCase) >= 0 || s.Artist.IndexOf(e.NewTextValue, StringComparison.OrdinalIgnoreCase) >= 0 || s.Album.IndexOf(e.NewTextValue, StringComparison.OrdinalIgnoreCase) >= 0 ); } CatalogView.EndRefresh(); }
public IActionResult Products(int?sectionId, int?brandId) { var products = _products.GetProducts(new ProductFilter { SectionId = sectionId, BrandId = brandId }); var model = new CatalogView() { BrandId = brandId, SectionId = sectionId, Products = products.Select(p => new ProductView() { Id = p.Id, Name = p.Name, Order = p.Order, ImageUrl = p.ImageUrl, Price = p.Price }).OrderBy(p => p.Order).ToList() }; return(View(model)); }
public ActionResult UpdateCatalog(CatalogView catalog) { try { var article = Article.Find(catalog.Id); if (article != null) { article.Name = catalog.Name; article.Order = catalog.Order; article.ParentId = catalog.ParentId; article.Save(); return(this.Json(new ActionResultStatus(), JsonRequestBehavior.AllowGet)); } return(this.Json(new ActionResultStatus(10, "目录不存在!"), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(this.Json(new ActionResultStatus(ex), JsonRequestBehavior.AllowGet)); } }
private void InitCommands() { Search = new RelayCommand(x => { var SV = new SearchView(); (SV.DataContext as SearchViewModel).SearchText = SearchText; (SV.DataContext as SearchViewModel).Search.Execute(this); CurrentView = SV; }); Catalog = new RelayCommand(x => { CurrentView = new CatalogView(); }); Basket = new RelayCommand(x => { CurrentView = new BasketView(); }); Wishlist = new RelayCommand(x => { CurrentView = new WishlistView(); }); }
internal Form RenderMainView() { InitSearchView(); catalogView = new CatalogView(moviesGridViewModel, new DirectorsAutocompleteSource(directorRepository), new ActorsAutocompleteSource(actorRepository)); catalogView.RefillDatabase += (async() => { await actorRepository.DropAll(); await directorRepository.DropAll(); await movieRepository.DropAll(); await DefaultDataHelper.FillRepositories(movieRepository, directorRepository, actorRepository); GetMovies(); }); catalogView.SaveMovie += SaveMovie; catalogView.DeleteFilm += DeleteMovie; catalogView.EditFilm += (List <Movie> selected) => { if (selected.Count > 0) { var movie = selected[0]; editMovieViewModel = new EditMovieViewModel(); catalogView.ShowMovieEditForm(editMovieViewModel); editMovieViewModel.MovieId = movie.MovieId; editMovieViewModel.Name = movie.Name; editMovieViewModel.Year = movie.Year; editMovieViewModel.Country = movie.Country; editMovieViewModel.Image = movie.Image; editMovieViewModel.Actors = new List <Actor>(movie.Actors); editMovieViewModel.Director = movie.Director; } }; catalogView.AddMovieActor += (async(name) => { var query = actorRepository.GetAll().Where(actor => actor.Name == name); var foundActor = (await actorRepository.ToListAsync(query)).FirstOrDefault(); if (foundActor != null) { editMovieViewModel.Actors.Add(foundActor); } else { var newActor = new Actor() { Name = name }; await actorRepository.Save(newActor); editMovieViewModel.Actors.Add(newActor); } }); catalogView.FindFilm += (() => { if (searchView.IsDisposed) { InitSearchView(); } searchView.Show(); searchView.Activate(); searchView.Left = catalogView.Left + catalogView.Width / 2 - searchView.Width / 2; catalogView.FindMovieMenuItem.Checked = true; catalogView.ExitMenuItem.Enabled = false; }); catalogView.GoBack += (() => { GetMovies(); catalogView.ShowMovieGrid(); }); catalogView.AboutOpen += (() => { var aboutView = new AboutView(); aboutView.ShowDialog(); }); catalogView.DeleteActor += ((position) => { editMovieViewModel.ActorsRemoveAt(position); }); getMovies.OnStarted += (() => { catalogView.SetEnabledState(false); catalogView.SetGridStatus(false); catalogView.SetGridTitle(Properties.Resources.GridTitleLoading); }); GetMovies(); return(catalogView); }
public MainWindow(CatalogView catalog) { InitializeComponent(); Shell.Children.Add(catalog); }
protected internal override Catalog toObject(CatalogView v) => new CatalogViewFactory().Create(v);