public async Task <IActionResult> AddCategoryIcon(CreateCategoryIconRequest request) { var currentVersion = await _catalogContext .Versions .Where(y => y.Type.Equals(request.Type) && y.Language.Equals(request.Language)) .SingleAsync(); if (currentVersion == null) { return(BadRequest()); } string imageFileExtension = Path.GetExtension(request.Image.FileName); var webRoot = _env.WebRootPath; var dir = webRoot; //Path.Combine(webRoot, "Pics"); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var fileName = string.Format("{0}_{1}_{2}_{3}_{4}{5}", request.Language, request.Type, request.CategoryName, request.SubcategoryName, currentVersion.VersionNumber.ToString(), imageFileExtension); var path = Path.Combine(dir, fileName); using (var stream = new FileStream(path, FileMode.Create)) { await request.Image.CopyToAsync(stream); } Size size = ImageHelper.GetDimensions(path); var item = new CategoryIcon { Name = request.Name, //IconUri = categoryIcon.IconUri, IconFileName = fileName, SubcategoryName = request.SubcategoryName, CategoryName = request.CategoryName, Type = request.Type, Order = request.Order, VersionNumber = currentVersion.VersionNumber, Width = size.Width, Height = size.Height, Language = request.Language }; _catalogContext.CategoryIcons.Add(item); await _catalogContext.SaveChangesAsync(); return(CreatedAtAction(nameof(GetCategoryIconById), new { id = currentVersion.Id }, null)); }
public CategoriesDashBoardViewModel() { Icon = new CategoryIcon(); CommonCategories = IoC.Get <CategoriesViewModel>(); CommonCategories.CategoryType = CategoryType.Common; WithdrawalCategories = IoC.Get <CategoriesViewModel>(); WithdrawalCategories.CategoryType = CategoryType.Withdrawal; DepositCategories = IoC.Get <CategoriesViewModel>(); DepositCategories.CategoryType = CategoryType.Deposit; repository.Entities.CollectionChanged += (sender, args) => NotifyOfPropertyChange(() => Name); Translator.CultureChanged += (sender, args) => NotifyOfPropertyChange(() => Name); }
private void CategoryView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { CategoryIcon nv = args.ItemContainer.ContentTemplateRoot as CategoryIcon; if (nv != null) { nv.AddData(args.Item as MainPageCategoryData); if (4 * 80 > (DiveRect.Width - 32)) { nv.Width = nv.Height = (DiveRect.Width - 32) / 4; nv.RootGrid.Width = nv.RootGrid.Height = nv.Width - 2; nv.IMG.Width = nv.IMG.Height = nv.IMG.Width - 5; nv.RootGrid.Margin = new Thickness(0, 2, 0, -2); nv.Title.FontSize = 13; nv.Title.Margin = new Thickness(0, 0, 5, 0); } } }