public ActionResult Index() { using (var context = new Context()) { var collection = _getCollection(context); var model = new CollectionVM { CardCount = collection.Cards.Sum(c => c.Amount), UniqueCardCount = collection.Cards.Count }; if (collection.Cards != null && collection.Cards.Count > 0) { model.Stats = collection.Cards.GroupBy(c => c.Card.Set).Select(s => new StatsVM { Set = s.Key.Name, Amount = s.Sum(c => c.Amount), UniqueAmount = s.Count(), TotalWorth = _getTotalWorth(s.ToList()) }).OrderByDescending(m => m.Amount).ToList(); } return(View(model)); } }
public void SetFilter(CollectionVM collection, FilterExpressionData filter) { _collection = collection; Elements = collection.AvailableProperties; if (filter != null) { var fge = new FilterGroupEditor(collection, false, this.IsReadOnly, this); fge.SetFilter(filter); this.FilterExpr = filter; SetRootGroup(fge); if (filter != null) { gStartPanel.Visibility = Visibility.Collapsed; MyBorder.Visibility = System.Windows.Visibility.Visible; if (!IsReadOnly) { spButtons.Visibility = System.Windows.Visibility.Visible; } } } else { this.setProperty(PropertyDefinitionModel.GetEmpty()); } }
// GET: Admin/Collection/Create public ActionResult Create() { ViewBag.VendorId = new SelectList(db.vendors, "Id", "Title"); CollectionVM model = new CollectionVM(); return(View(model)); }
public FilterAtomEditor(CollectionVM collection, FltAtomExprData filter) { InitializeComponent(); var field = collection.AvailableProperties.FirstOrDefault(p => p.Path == filter.Field); Filter = filter; IsWithEntityIdFilter = false; setField(field); }
public void SetCollection(CollectionVM collection) { if (collection != null) { _collection = collection; Elements = collection.AvailableProperties; } Reset(); }
public static IEnumerable <FilterElementDefinition> GetFilterEditorElements(CollectionVM collection) { if (collection != null) { var retList = new List <FilterElementDefinition>(); foreach (var prop in collection.AvailableProperties) { retList.Add(FilterElementDefinition.GetFieldFilterElement(prop)); } return(retList); } return(new List <FilterElementDefinition>()); }
public FilterElementEditor(CollectionVM collection, FltAtomExprData filter, bool isPopupMode) { this.IsPopupMode = isPopupMode; InitializeComponent(); this.propSelector.SelectedPropertyChanged += PropSelector_SelectedPropertyChanged; Filter = filter; this.propSelector.Properties = collection.AvailableProperties; this.propSelector.SelectedProperty = new PropertyDefinitionModel { Path = filter.Field, Name = filter.Field, Type = filter.PropertyType }; IsWithcollectionIdFilter = false; setField(this.propSelector.SelectedProperty); }
public ActionResult Create(CollectionVM model, HttpPostedFileBase file) { if (db.collections.Any(x => x.Title.Equals(model.Title))) { ModelState.AddModelError("", "Sorry, the collection name already exists"); ViewBag.VendorId = new SelectList(db.vendors, "Id", "Title"); return(View(model)); } if (ModelState.IsValid) { if (file == null || file.ContentLength == 0) { ModelState.AddModelError("", "Sorry you did not upload any image"); ViewBag.VendorId = new SelectList(db.vendors, "Id", "Title"); return(View(model)); } Collection collection = new Collection { Title = model.Title, Description = model.Description, VendorId = model.VendorId }; db.collections.Add(collection); db.SaveChanges(); if (!ExtensionMethods.saveImage(collection.Id, file, "Collections")) { ModelState.AddModelError("", "The image file you uploaded might be of wrong format"); ViewBag.VendorId = new SelectList(db.vendors, "Id", "Title"); return(View(model)); } else { collection.ImageUrl = file.FileName; db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.VendorId = new SelectList(db.vendors, "Id", "Title", model.VendorId); return(View(model)); }
public FilterElementEditor(CollectionVM collection, PropertyDefinitionModel elementDef, bool isPopupMode) { this.IsPopupMode = isPopupMode; InitializeComponent(); this.propSelector.SelectedPropertyChanged += PropSelector_SelectedPropertyChanged; IsWithcollectionIdFilter = false; var field = elementDef; this.propSelector.Properties = collection.AvailableProperties; this.propSelector.SelectedProperty = elementDef; Filter = new FltAtomExprData() { Operator = FilterFieldOperator.Equal, PropertyType = field.Type, Field = field.Path }; setField(field); }
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (e.Property == CollectionProperty && _collection != e.NewValue as CollectionVM) { if (_fePopupControl != null) { _fePopupControl.SetCollection(e.NewValue as CollectionVM); _collection = e.NewValue as CollectionVM; if (this.FilterExpr != null) { _fePopupControl.SetFilter(_collection, FilterExpr); } } else { _collection = e.NewValue as CollectionVM; } } else if (e.Property == FilterExprProperty) { if (_fePopupControl != null && this._collection != null) { _fePopupControl.SetFilter(this._collection, e.NewValue as FilterExpressionData); } else { this.FilterExpr = e.NewValue as FilterExpressionData; } if (this.FilterExpr != null && FilterExpr.HasActiveFilter) { this.ActiveBackground = Brushes.Red; } else { this.ActiveBackground = Brushes.Transparent; } } else if (e.Property == UpdateFilterFunctionProperty && this._fePopupControl != null) { this._fePopupControl.UpdateFilterFunction = UpdateFilter; } }
// GET: Admin/Collection/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Collection collection = db.collections.Find(id); CollectionVM model = new CollectionVM(collection); model.VendorName = db.vendors.Where(x => x.Id.Equals(model.VendorId)).FirstOrDefault().Title; if (collection == null) { return(HttpNotFound()); } return(View(model)); }
public ObservableCollection <CollectionVM> LoadCollections(ObservableCollection <LauncherVM> launchers) { //todo :make paths relative ObservableCollection <CollectionVM> collections = new ObservableCollection <CollectionVM>(); string[] dirs = Directory.GetDirectories(RetroFE.GetAbsolutePath() + "/Collections"); foreach (string dir in dirs) { string settingsFile = Path.Combine(dir, "Settings.conf"); string menuFile = Path.Combine(dir, "Menu.xml"); CollectionVM vm = new CollectionVM(); ConfFileParser ini = new ConfFileParser(settingsFile); MenuParser mp = new MenuParser(); string launcher = ini.GetSetting("launcher"); vm.Name = System.IO.Path.GetFileNameWithoutExtension(dir); vm.Launcher = launchers.FirstOrDefault(row => row.Name == launcher); vm.ListPath = ini.GetSetting("list.path"); vm.Layout = ini.GetSetting("layout"); if (vm.Layout == "") { vm.IsDefaultLayout = true; } vm.FileExtensions = ini.GetSetting("list.extensions"); vm.MediaPathVideo = ini.GetSetting("media.video"); vm.MediaPathTitle = ini.GetSetting("media.title"); vm.MediaPathLogo = ini.GetSetting("media.logo"); vm.MediaPathTitle = ini.GetSetting("media.title"); vm.MediaPathSnap = ini.GetSetting("media.snap"); vm.MediaPathBox = ini.GetSetting("media.box"); vm.MediaPathCart = ini.GetSetting("media.cart"); //todo: read submenus vm.Submenus = mp.ReadCollections(menuFile); collections.Add(vm); } return(collections); }
// GET: Admin/Collection/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Collection collection = db.collections.Find(id); if (collection == null) { return(HttpNotFound()); } CollectionVM model = new CollectionVM(collection); model.VendorName = db.vendors.Where(x => x.Id.Equals(model.VendorId)).FirstOrDefault().Title; ViewBag.VendorId = new SelectList(db.vendors, "Id", "Title", model.VendorId); return(View(model)); }
public IActionResult Collection(int id) { Collections c = collectionRepository.GetCollectionById(id); CollectionVM model = new CollectionVM(); model.Artworks = new List <ArtworkVM>(); List <ArtworkCollections> artworks = artworkcollectionRepository.GetArtworkCollections(c.Id); foreach (ArtworkCollections art in artworks) { ArtworkVM vm = new ArtworkVM(); vm.Id = art.ArtworkId; vm.Name = art.Artwork.Name; vm.Artist = art.Artwork.Artist.Name; vm.Image = imageRepository.GetArtworkImage(art.ArtworkId); vm.Museum = art.Artwork.Museum.Name; if (vm.Image != null) { vm.ImageId = vm.Image.Id; } vm.Liked = false; model.Artworks.Add(vm); } model.Image = c.Image; if (model.Image != null) { model.ImageId = model.Image.Id; } model.Description = c.Description; model.Id = c.Id; model.MuseumId = c.MuseumId; model.Name = c.Name; return(View("Collection", model)); }
public ActionResult Edit(CollectionVM model, HttpPostedFileBase file) { if (db.collections.Where(x => x.Title != model.Title).Any(x => x.Title.Equals(model.Title))) { ModelState.AddModelError("", "Sorry this collection name already exists."); return(View(model)); } if (ModelState.IsValid) { Collection collection = db.collections.Where(x => x.Id.Equals(model.Id)).FirstOrDefault(); if (file != null && file.ContentLength > 0) { ExtensionMethods.DeleteImage(collection.Id, "Collections"); if (ExtensionMethods.saveImage(collection.Id, file, "Collections")) { collection.ImageUrl = file.FileName; } else { ModelState.AddModelError("", "The image file you uploaded might be of wrong format"); return(View(model)); } } collection.Title = model.Title; collection.Description = model.Description; collection.VendorId = model.VendorId; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.VendorId = new SelectList(db.vendors, "Id", "Title", model.VendorId); return(View(model)); }
public FilterGroupEditor(CollectionVM collection, bool vertical, bool isReadOnly, FilterEditor editorContext) { InitializeComponent(); this.IsPopupMode = editorContext.IsPopupMode; EditorContext = editorContext; _collection = collection; if (collection != null) { Elements = collection.AvailableProperties; } else { Elements = new List <PropertyDefinitionModel>(); } SubGroups = new List <FilterGroupEditor>(); _vertical = vertical; this.VerticalAlignment = VerticalAlignment.Center; this.HorizontalAlignment = HorizontalAlignment.Center; if (!_vertical) { Orientation = Orientation.Horizontal; } else { Orientation = Orientation.Vertical; } IsReadOnly = false; popupFieldSelect.Opened += (sender, args) => { if (EditorContext != null) { EditorContext.EntityFieldsPopups.Add(popupFieldSelect); } }; this.IsReadOnly = isReadOnly; }
public FilterGroupEditor(CollectionVM collection, bool vertical, bool isReadOnly, FilterEditor editorContext, FilterExpressionData filter) : this(collection, vertical, isReadOnly, editorContext) { SetFilter(filter); }