private Action <IEnumerable <CategoryItemViewModel> > CreateAppender(Func <HierarchyItemViewModel> itemGetter) { return(categories => { HierarchyItemViewModel item = itemGetter(); if (item != null) { List <CategoryItemViewModel> previousCategories = item.Categories; item.Expanded = true; item.Categories = categories.ToList(); item.Categories.ForEach( cate => { CategoryItemViewModel previousCategory = previousCategories.FirstOrDefault(pcate => pcate.Category.CategoryId == cate.Category.CategoryId); if (previousCategory != null) { cate.Expanded = previousCategory.Expanded; cate.Selected = previousCategory.Selected; cate.Categories = previousCategory.Categories; } } ); } }); }
public IActionResult Index(Category Category) { CategoryViewModel CategoryViewModel = new CategoryViewModel(); CategoryViewModel.Category = new Category(); List <Category> CategoryList = _db.Categories.ToList(); List <CategoryItemViewModel> CategoryItemList = new List <CategoryItemViewModel>(); if (ModelState.IsValid) { _db.Categories.Add(Category); _db.SaveChanges(); foreach (var item in CategoryList) { CategoryItemViewModel CategoryItem = new CategoryItemViewModel(); CategoryItem.Category = item; CategoryItem.Items = _db.Items.Where(x => x.CategoryId == item.CategoryId).ToList(); CategoryItemList.Add(CategoryItem); } CategoryViewModel.CategoryItemViewModel = CategoryItemList; } return(View(CategoryViewModel)); }
public IActionResult Create() { OrderCategoryItemViewModel CustomerCategory = new OrderCategoryItemViewModel(); List <CategoryItemViewModel> CategoryItemList = new List <CategoryItemViewModel>(); List <PaymentMethod> PaymentMethodList = _db.PaymentMethods.ToList(); List <Category> CategoryList = _db.Categories.ToList(); foreach (var item in CategoryList) { CategoryItemViewModel CategoryItem = new CategoryItemViewModel(); CategoryItem.Category = item; CategoryItem.Items = _db.Items.Where(x => x.CategoryId == item.CategoryId).ToList(); CategoryItemList.Add(CategoryItem); } CustomerCategory.Customer = new Customer(); CustomerCategory.CategoryItemViewModel = CategoryItemList; CustomerCategory.PaymentMethod = PaymentMethodList; return(View(CustomerCategory)); }
public ActionResult <int> Post([FromBody] CategoryItemViewModel value) { CategoryItem item = new CategoryItem(); item.Name = value.Name; item.Noise = value.Noise; return(_db.AddCategoryItem(item)); }
public CategoryOperationEventArgs(CategoryItemViewModel category) { if (category == null) { throw new ArgumentNullException(nameof(category)); } Category = category; }
public ActionResult <bool> Put(int id, [FromBody] CategoryItemViewModel value) { CategoryItem item = new CategoryItem(); item.Id = id; item.Name = value.Name; item.Noise = value.Noise; return(_db.UpdateCategoryItem(item)); }
public async Task <IActionResult> Index() { var vm = new BooksViewModel(); var allBooks = await _bookService.ReadAllAsync(); var allCategories = await _categoryService.ReadAllAsync(); var allCategoryAreas = await _categoryAreaService.ReadAllAsync(); foreach (var area in allCategoryAreas.OrderBy(ca => ca.Name)) { var areaVm = new CategoryAreaItemViewModel { Id = area.Id, Name = area.Name, Ref = $"area-{area.Id}" }; var categories = allCategories.Where(c => c.CategoryArea?.Id == area.Id) .OrderBy(c => c.Name) .ToList(); foreach (var category in categories) { var categoryVm = new CategoryItemViewModel { Id = category.Id, Name = category.Name, Ref = $"category-{category.Id}" }; var books = allBooks.Where(b => b.Category?.Id == category.Id) .OrderByDescending(b => b.PublishYear) .ThenBy(b => b.Name) .ToList(); foreach (var book in books) { var bookVm = new BookItemViewModel { Id = book.Id, Title = book.Name, Year = book.PublishYear, Authors = book.Authors, Rating = book.Rating, ImageUrl = book.ImageUri, AmazonUrl = book.AmazonUri, DownloadUrl = book.ContentUri, Reflection = book.Reflection }; categoryVm.Books.Add(bookVm); } areaVm.Categories.Add(categoryVm); } vm.CategoryAreas.Add(areaVm); } return(View(vm)); }
private Boolean Contains(IEnumerable <CategoryItemViewModel> categories, CategoryItemViewModel searchCategory) { foreach (CategoryItemViewModel category in categories) { if (category == searchCategory || this.Contains(category.Categories, searchCategory)) { return(true); } } return(false); }
public ActionResult Delete(CategoryItemViewModel model) { var cat = _context.Categories.SingleOrDefault(x => x.Id == model.Id); if (cat != null) { _context.Categories.Remove(cat); _context.SaveChanges(); } return(RedirectToAction("Index")); }
public async Task <IActionResult> AddToBasket(CategoryItemViewModel productDetails) { if (productDetails?.Id == null) { return(RedirectToAction("Index", "Catalog")); } var basketViewModel = await GetBasketViewModelAsync(); await _basketService.AddItemToBasket(basketViewModel.Id, productDetails.Id, productDetails.Price, 1); return(RedirectToAction("Index")); }
public IActionResult Delete(CategoryItemViewModel model) { BaseWebServiceResponse response = _categoryWebService.Delete(model.Id); TempData[CategoryActionName] = response; if (!response.ActionSuccessful) { return(View($"{CategoryActionName}/Index.cshtml", model)); } return(RedirectToAction("Index", "Categories")); }
public async Task <IActionResult> OnPost(CategoryItemViewModel productDetails) { if (productDetails?.Id == null) { return(View("Index", CartModel)); } await SetCartModelAsync(); await _cartService.AddToCart(CartModel.Id, productDetails.Id, productDetails.Price, 1); await SetCartModelAsync(); return(View("Index", CartModel)); }
private bool IsValidDropTarget(DragEventArgs e, out CategoryItemViewModel dragSource, out CategoryItemViewModel dropTarget) { dragSource = null; dropTarget = (CategoryItemViewModel)DataContext; if (e.Data.GetDataPresent(typeof(CategoryItemViewModel))) { dragSource = (CategoryItemViewModel)e.Data.GetData(typeof(CategoryItemViewModel)); if (dragSource != dropTarget) { return(true); } } return(false); }
public CategoryItemViewModel GetCategoryDetails(int id) { CategoryItemViewModel model = null; var category = _recipeCategoryRepository.GetRecipeCategoryById(id); if (category != null) { model = new CategoryItemViewModel { Id = category.Id, NameRecipeCategory = category.NameRecipeCategory, IsPublished = category.IsPublished }; } return(model); }
public ActionResult DeleteCategory(CategoryItemViewModel category) { bool success = GetCommand <DeleteCategoryCommand>().ExecuteCommand( new DeleteCategoryCommandRequest { CategoryId = category.Id, Version = category.Version }); if (success) { Messages.AddSuccess(PagesGlobalization.DeleteCategory_DeletedSuccessfully_Message); } return(Json(new WireJson(success))); }
/// <summary> /// Extension method that returns an instance of <see cref="QAViewModel"/> from <see cref="CategoryItemViewModel"/>. /// </summary> /// <param name="categoryViewModel">Category Item View Model instance.</param> /// <returns>Instance of QAViewModel.</returns> public static QAViewModel ToQAViewModel(this CategoryItemViewModel categoryViewModel) { if (categoryViewModel == null) { return(null); } return(new QAViewModel() { AllDay = categoryViewModel.AllDay, Description = categoryViewModel.Description, End = categoryViewModel.End, Id = categoryViewModel.Id, Start = categoryViewModel.Start, Title = categoryViewModel.Title }); }
public ActionResult CreateCategoryItem(CategoryItemViewModel categoryItem) { if (!ModelState.IsValid) { return(View(categoryItem)); } Mapper.CreateMap <CategoryItemViewModel, CategoryItemDTO>() .ForMember(x => x.MenuCategoryId, m => m.MapFrom(s => s.CategoryId)) .ForMember(x => x.ActionName, m => m.MapFrom(s => s.ActionName)) .ForMember(x => x.ControllerName, m => m.MapFrom(s => s.ControllerName)) .ForMember(x => x.Name, m => m.MapFrom(s => s.Name)); var item = Mapper.Map <CategoryItemViewModel, CategoryItemDTO>(categoryItem); _menuService.CreateCategoryItem(item); return(RedirectToAction("CategoryItemList")); }
public ActionResult CategoryItem(int?id) { TempData["shoppingURL"] = Request.Url.PathAndQuery; if (TempData["itemList"] != null) { //return Content("some some in temp data itemlist"); TempData.Keep("itemList"); } CategoryItemViewModel viewM = new CategoryItemViewModel(); viewM.ProductList = new List <CategoryItemModel>(); var queryProduct = (from o in db.Products where o.ProductID > 1 && o.CategoryID == id select o).ToList(); foreach (Product item in queryProduct) { CategoryItemModel tempInstance = new CategoryItemModel(); tempInstance.ImgLocation = item.ProductImageLocation; tempInstance.ProductID = item.ProductID; tempInstance.ProductName = item.ProductName; tempInstance.UnitPrice = item.ProductPrice; if (item.ProductDescription.Length > 12) { tempInstance.ProductDescription = item.ProductDescription.Substring(0, 12) + "⋯"; } else { tempInstance.ProductDescription = item.ProductDescription; } tempInstance.QuantityInStock = (int)item.ProductQuantity; viewM.ProductList.Add(tempInstance); } return(View(viewM)); }
public IActionResult SaveItems(CategoryItemViewModel c) { var item = _context.Items.Where(f => f.ItemId == c.ItemId).FirstOrDefault(); if (item.CategId == c.CategoryId) { if (c.IsChoosed == false) { item.CategId = null; _context.SaveChanges(); } } if (c.IsChoosed == true) { item.CategId = c.CategoryId; _context.SaveChanges(); } return(Ok(item)); }
public static List <CategoryItemViewModel> categoryQueryById(string catId) { DataTable dtCombo = new DataTable(); CategoryAccess _access = new CategoryAccess(); dtCombo = _access.Category_Query("Q", catId, ""); List <CategoryItemViewModel> result = new List <CategoryItemViewModel>(); foreach (DataRow dtr in dtCombo.Rows) { CategoryItemViewModel item = new CategoryItemViewModel { DATATEXTFIELD = dtr["DATATEXTFIELD"].ToString(), DATAVALUEFIELD = dtr["DATAVALUEFIELD"].ToString() }; result.Add(item); } return(result); }
/// <summary> /// Extension method that returns an instance of <see cref="CategoryItemViewModel"/> from <see cref="QAViewModel"/>. /// </summary> /// <param name="categoryViewModel"></param> /// <param name="model"></param> /// <returns></returns> public static CategoryItemViewModel ToCategoryItemViewModel(this QAViewModel model, CategoryItemViewModel categoryViewModel = null) { if (categoryViewModel == null) { categoryViewModel = new CategoryItemViewModel(); } if (model == null) { return(null); } categoryViewModel.AllDay = model.AllDay; categoryViewModel.Description = model.Description; categoryViewModel.End = model.End; categoryViewModel.Id = model.Id; categoryViewModel.Start = model.Start; categoryViewModel.Title = model.Title; return(categoryViewModel); }
public IActionResult GetItems(int CategoryId) { //ana bde red list mn categoryitemviewmodel yale khasson bhyda l catgid var allitems = _context.Items.ToList(); var catsitems = new List <CategoryItemViewModel>(); foreach (var a in allitems) { var c = new CategoryItemViewModel(); c.CategoryId = CategoryId; c.ItemId = a.ItemId; c.ItemName = a.ItemName; int exist = -1; if (a.CategId == CategoryId) { exist = 0; //it belongs to this category } else if (a.CategId != null) { exist = 1;//it belongs to another category } else { exist = 2;//it doesn't belong to any category } if (exist == 0) { c.IsChoosed = true; } if (exist == 2) { c.IsChoosed = false; } if (exist != 1) { catsitems.Add(c); } } return(Ok(catsitems)); }
public ActionResult SaveCategory(CategoryItemViewModel category) { if (ModelState.IsValid) { var response = GetCommand <SaveCategoryCommand>().ExecuteCommand(category); if (response != null) { if (category.Id.HasDefaultValue()) { Messages.AddSuccess(PagesGlobalization.CreateCategory_CreatedSuccessfully_Message); } return(Json(new WireJson { Success = true, Data = response })); } } return(Json(new WireJson { Success = false })); }
private DropActionEnum GetDropAction(DragEventArgs e, CategoryItemViewModel dropTarget) { var delta = e.GetPosition(this).Y / _headerElement.ActualHeight * 100; if (dropTarget.Properties is GenericPropertiesViewModel) { if (delta < 27) { return(DropActionEnum.InsertBefore); } if (delta < 75) { return(DropActionEnum.Add); } return(DropActionEnum.InsertAfter); } if (delta < 50) { return(DropActionEnum.InsertBefore); } return(DropActionEnum.InsertAfter); }
public IActionResult Index() { CategoryViewModel CategoryViewModel = new CategoryViewModel(); CategoryViewModel.Category = new Category(); List <Category> CategoryList = _db.Categories.ToList(); List <CategoryItemViewModel> CategoryItemList = new List <CategoryItemViewModel>(); foreach (var item in CategoryList) { CategoryItemViewModel CategoryItem = new CategoryItemViewModel(); CategoryItem.Category = item; CategoryItem.Items = _db.Items.Where(x => x.CategoryId == item.CategoryId).ToList(); CategoryItemList.Add(CategoryItem); } CategoryViewModel.CategoryItemViewModel = CategoryItemList; return(View(CategoryViewModel)); }
public ConnectionSettingsViewModel(CategoryItemViewModel parent) : base(parent) { }
public CredentialsViewModel(CategoryItemViewModel parent) { Parent = parent; }
public GenericPropertiesViewModel(CategoryItemViewModel parent) { Parent = parent; }
private CatalogItemViewModel GetCatalog(HierarchyViewModel hierarchy, CategoryItemViewModel category) { return(hierarchy.FirstOrDefault(cata => this.Contains(cata.Categories, category))); }
private void UpdateState(ProductListPart part, ProductListViewModel viewModel) { String previousCatalogCodeFilter = viewModel.State.CatalogCodeFilter ?? String.Empty; String previousCategoryCodeFilter = viewModel.State.CategoryCodeFilter ?? String.Empty; if (part.FromCatalogHierarchySelection) { HierarchyViewModel hierarchy; HierarchyItemViewModel selectedItem; CatalogHierarchyPart catalogHierarchyPart; if ( part.CatalogHierarchyId.HasValue && (catalogHierarchyPart = this._orchardServices.ContentManager.Get <CatalogHierarchyPart>(part.CatalogHierarchyId.Value, VersionOptions.Published)) != null && !catalogHierarchyPart.GenerateUrls && (hierarchy = this._catalogHierarchyServices.GetModel(catalogHierarchyPart)) != null && (selectedItem = this.GetSelected(hierarchy)) != null ) { if (selectedItem is CatalogItemViewModel) { CatalogItemViewModel catalog = (CatalogItemViewModel)selectedItem; viewModel.State.CatalogCodeFilter = catalog.Catalog.Code; viewModel.State.CategoryCodeFilter = null; } else if (selectedItem is CategoryItemViewModel) { CategoryItemViewModel category = (CategoryItemViewModel)selectedItem; viewModel.State.CatalogCodeFilter = this.GetCatalog(hierarchy, category).Catalog.Code; viewModel.State.CategoryCodeFilter = category.Category.Code; } viewModel.State.FromPath = this.GetPath(hierarchy, selectedItem); } else { viewModel.State.FromPath = viewModel.State.CatalogCodeFilter = viewModel.State.CategoryCodeFilter = null; } } else { viewModel.State.CatalogCodeFilter = part.CatalogCodeFilter; viewModel.State.CategoryCodeFilter = part.CategoryCodeFilter; } if (this._target == part.Id) { viewModel.State.Page = this._page; viewModel.State.SortDirection = this._sortDirection; viewModel.State.SortExpression = this._sortExpression; } Boolean hasSortExpression = !String.IsNullOrEmpty(viewModel.State.SortExpression); Boolean hasCatalogFilter = !String.IsNullOrEmpty(viewModel.State.CatalogCodeFilter); Boolean hasCategoryFilter = !String.IsNullOrEmpty(viewModel.State.CategoryCodeFilter); if (part.EnableSorting) { if (!viewModel.State.SortDirection.HasValue) { viewModel.State.SortDirection = SortDirection.Ascending; } if (!hasSortExpression) { viewModel.State.SortExpression = hasCategoryFilter ? "custom" : this.GetPropertyName <ReferenceProduct, String>(rp => rp.Name); } else if ("custom".EqualsOrdinalIgnoreCase(viewModel.State.SortExpression) && !hasCategoryFilter) { viewModel.State.SortExpression = this.GetPropertyName <ReferenceProduct, String>(rp => rp.Name); } } else { viewModel.State.SortDirection = SortDirection.Ascending; viewModel.State.SortExpression = String.IsNullOrEmpty(viewModel.State.CategoryCodeFilter) ? this.GetPropertyName <BaseProduct, String>(bp => bp.Name) : "custom"; } if ( (!previousCatalogCodeFilter.EqualsOrdinalIgnoreCase(viewModel.State.CatalogCodeFilter ?? String.Empty) && !this._page.HasValue) || (!previousCategoryCodeFilter.EqualsOrdinalIgnoreCase(viewModel.State.CategoryCodeFilter ?? String.Empty) && !this._page.HasValue) || !part.EnablePaging || viewModel.State.Page < 1 || !viewModel.State.Page.HasValue ) { viewModel.State.Page = 1; } }