public ProductsFilterPane(ProductCollectionViewModel collectionViewModel) : base(() => CreateViewModel(() => new ProductsFilterTreeViewModel(collectionViewModel))) { InitializeComponent(); FiltersTreeListAppearances.Apply(treeList); this.presenterCore = CreatePresenter(); BindCommands(); }
public ProductsFilterPaneCollapsed(ProductCollectionViewModel collectionViewModel) : base(() => CreateViewModel(() => new ProductsFilterTreeViewModel(collectionViewModel))) { InitializeComponent(); presenterCore = CreatePresenter(); BindCommands(); }
public ProductsFilterPaneCollapsed(ProductCollectionViewModel collectionViewModel) : base(typeof(ProductsFilterTreeViewModel), new object[] { collectionViewModel }) { InitializeComponent(); presenterCore = CreatePresenter(); BindCommands(); }
public IActionResult GetById(string id) { if (id == null) { return(this.View()); } var rqf = Request.HttpContext.Features.Get <IRequestCultureFeature>(); // Culture contains the information of the requested culture var culture = rqf.RequestCulture.Culture; ViewData["Culture"] = culture.Name; var products = this._productService .GetAllProductsForCategoryById(id); foreach (var product in products) { var pictures = this._pictureService.GetAllProductPicturesById(product.Id); product.Pictures = pictures; } var productsView = new ProductCollectionViewModel { Products = products }; return(this.View(productsView)); }
public ProductsFilterPane(ProductCollectionViewModel collectionViewModel) : base(typeof(ProductsFilterTreeViewModel), new object[] { collectionViewModel }) { InitializeComponent(); FiltersTreeListAppearances.Apply(treeList); this.presenterCore = CreatePresenter(); BindCommands(); }
public ActionResult CurrentEdit() { ProductCollectionViewModel productCollectionViewModel = ProductCollectionViewModel.BuildByNameAlphabetical(SessionHelper.GetCurrentProductId( User.Identity.Name, Session)); return(PartialView(productCollectionViewModel)); }
public async Task <ActionResult> Delete([FromQuery] ProductCollectionViewModel model) { var originData = await productCollectionService.FindByIdAsync(model.ID); originData.Active = false; await this.productCollectionService.DeactiveAsync(model.ID); return(Ok(BaseResponse <ProductCollectionViewModel> .PrepareDataSuccess(model, "Delete the artist successful!"))); }
/// <summary> /// ذخیره کالکشن در دیتابیس /// </summary> /// <param name="model">مدل حاوی اطلاعات کالکشن</param> /// <returns>نتیجه ذخیره</returns> public JsonResult Save(ProductCollectionViewModel model) { Response response; try { var currentUser = GetAuthenticatedUser(); string oldFileName = ""; using (var db = new KiaGalleryContext()) { if (model.id > 0) { var entity = db.ProductCollection.SingleOrDefault(x => x.Id == model.id); entity.Title = model.title; entity.Active = model.active; entity.FileName = model.fileName; entity.ModifyUserId = currentUser.Id; entity.ModifyDate = DateTime.Now; if (!string.IsNullOrEmpty(entity.FileName) && entity.FileName != model.fileName) { oldFileName = entity.FileName; } } else { var entity = new ProductCollection() { Title = model.title, Active = model.active, FileName = model.fileName, CreateUserId = currentUser.Id, ModifyUserId = currentUser.Id, CreateDate = DateTime.Now, ModifyDate = DateTime.Now, }; db.ProductCollection.Add(entity); } db.SaveChanges(); if (!string.IsNullOrEmpty(oldFileName) && System.IO.File.Exists(Server.MapPath("~/Upload/ProductCollections/" + oldFileName))) { System.IO.File.Delete(Server.MapPath("~/Upload/ProductCollections/" + oldFileName)); } } response = new Response() { status = 200, message = "Done" }; } catch (Exception ex) { response = Core.GetExceptionResponse(ex); } return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult <ViewModelCollection <Product> > GetProducts() { var products = _products.GetAll(); if (!products.Any()) { return(NoContent()); } var vm = ProductCollectionViewModel.From(Request, products); return(Ok(vm)); }
/// <summary> /// Convert Product Collection to Slider /// Default type of product collection is in Slider Type Enum /// </summary> /// <param name="pc"></param> /// <returns></returns> private SliderViewModel ConvertProductCollectionToSlider(ProductCollectionViewModel pc) { var typeOfSlider = (int)SliderTypeEnum.ProductCollection; var slider = new SliderViewModel() { OriginalId = $"{typeOfSlider}-{pc.ID}", Type = typeOfSlider, IsSlider = pc.IsSlider, ThumbnailURL = pc.ThumbnailURL, Title = pc.Name, Slug = pc.Slug }; return(slider); }
public IActionResult GetAll() { var products = this._productService .GetAll(); foreach (var product in products) { var pictures = this._pictureService.GetAllProductPicturesById(product.Id); product.Pictures = pictures; } var productCollection = new ProductCollectionViewModel { Products = products }; return(View(productCollection)); }
public IHttpResponse Index() { if (this.User.IsLoggedIn) { var products = this.Context.Products .Select(p => new IndexProductViewModel { Id = p.Id, Name = p.Name, Price = p.Price, Description = p.Description }) .ToList(); var productCollection = new ProductCollectionViewModel { Products = products }; return(this.View("Home/LoggedIndex", productCollection)); } return(this.View()); }
public IActionResult Index() { if (this.User.Identity.IsAuthenticated) { var products = this.Context.Products .Select(p => new IndexProductViewModel { Id = p.Id, Name = p.Name, Price = p.Price, Description = p.Description }) .ToList(); var productCollection = new ProductCollectionViewModel { Products = products }; return(this.View(productCollection)); } return(this.View()); }
public async Task <ActionResult> Put([FromBody] ProductCollectionViewModel productRequestVM) { var productCollectionVM = await this.productCollectionService.UpdateAsync(productRequestVM.ID, productRequestVM); return(Ok(BaseResponse <ProductCollectionViewModel> .PrepareDataSuccess(productCollectionVM, "Update the artist successful!"))); }
public ActionResult ListByNameAlphabetical() { int currentProductId = SessionHelper.GetCurrentProductId(User.Identity.Name, Session); return(PartialView("List", ProductCollectionViewModel.BuildByNameAlphabetical(currentProductId))); }
public ProductCollectionPresenter(GridControl gridControl, ProductCollectionViewModel viewModel, System.Action <int> updateUIAction) : base(gridControl, viewModel, updateUIAction) { }
public ActionResult List(ProductSearchOption search, PagerRequest request) { int totalCount; search.CurrentUser = CurrentUser.CustomerId; search.CurrentUserRole = CurrentUser.Role; var dbContext = _productRepository.Context; var linq = dbContext.Set <ProductEntity>().Where(p => (!search.PId.HasValue || p.Id == search.PId.Value) && (string.IsNullOrEmpty(search.Name) || p.Name.StartsWith(search.Name)) && (!search.User.HasValue || p.CreatedUser == search.User.Value) && (!search.Status.HasValue || p.Status == (int)search.Status.Value) && p.Status != (int)DataStatus.Deleted); linq = _userAuthRepo.AuthFilter(linq, search.CurrentUser, search.CurrentUserRole) as IQueryable <ProductEntity>; if (!string.IsNullOrEmpty(search.Topic) && search.Topic.Trim().Length > 0) { linq = linq.Where(p => (from s in dbContext.Set <SpecialTopicEntity>() join ps in dbContext.Set <SpecialTopicProductRelationEntity>() on s.Id equals ps.SpecialTopic_Id where s.Name.StartsWith(search.Topic) && ps.Product_Id == p.Id select s).Any()); } if (!string.IsNullOrEmpty(search.Promotion) && search.Promotion.Trim().Length > 0) { linq = linq.Where(p => (from pr in dbContext.Set <PromotionEntity>() join ps in dbContext.Set <Promotion2ProductEntity>() on pr.Id equals ps.ProId where pr.Name.StartsWith(search.Promotion) && ps.ProdId == p.Id select pr).Any()); } var linq2 = linq.Join(dbContext.Set <StoreEntity>().Where(s => string.IsNullOrEmpty(search.Store) || s.Name.StartsWith(search.Store)), o => o.Store_Id, i => i.Id, (o, i) => new { P = o, S = i }) .Join(dbContext.Set <BrandEntity>().Where(b => string.IsNullOrEmpty(search.Brand) || b.Name.StartsWith(search.Brand)), o => o.P.Brand_Id, i => i.Id, (o, i) => new { P = o.P, S = o.S, B = i }) .Join(dbContext.Set <UserEntity>(), o => o.P.CreatedUser, i => i.Id, (o, i) => new { P = o.P, S = o.S, B = o.B, C = i }) .Join(dbContext.Set <TagEntity>().Where(t => string.IsNullOrEmpty(search.Tag) || t.Name.StartsWith(search.Tag)), o => o.P.Tag_Id, i => i.Id, (o, i) => new { P = o.P, S = o.S, B = o.B, C = o.C, T = i }) .GroupJoin(dbContext.Set <PromotionEntity>().Join(_pprRepository.GetAll(), o => o.Id, i => i.ProId, (o, i) => new { Pro = o, ProR = i }), o => o.P.Id, i => i.ProR.ProdId, (o, i) => new { P = o.P, S = o.S, B = o.B, C = o.C, T = o.T, Pro = i }) .GroupJoin(dbContext.Set <SpecialTopicEntity>().Join(_stprRepository.GetAll(), o => o.Id, i => i.SpecialTopic_Id, (o, i) => new { Spe = o, SpeR = i }), o => o.P.Id, i => i.SpeR.Product_Id, (o, i) => new { P = o.P, S = o.S, B = o.B, C = o.C, T = o.T, Pro = o.Pro, Spe = i }) .GroupJoin(dbContext.Set <ResourceEntity>().Where(r => r.SourceType == (int)SourceType.Product), o => o.P.Id, i => i.SourceId , (o, i) => new { P = o.P, S = o.S, B = o.B, C = o.C, T = o.T, Pro = o.Pro, Spe = o.Spe, R = i }); if (!search.OrderBy.HasValue) { linq2 = linq2.OrderByDescending(l => l.P.CreatedDate); } else { switch (search.OrderBy.Value) { case ProductSortOrder.CreatedUserDesc: linq2 = linq2.OrderByDescending(l => l.C.Nickname).ThenByDescending(l => l.P.CreatedDate); break; case ProductSortOrder.SortOrderDesc: linq2 = linq2.OrderByDescending(l => l.P.SortOrder).ThenByDescending(l => l.P.CreatedDate); break; case ProductSortOrder.SortByBrand: linq2 = linq2.OrderByDescending(l => l.B.Name).ThenByDescending(l => l.P.CreatedDate); break; case ProductSortOrder.CreatedDateDesc: linq2 = linq2.OrderByDescending(l => l.P.CreatedDate); break; } } totalCount = linq2.Count(); var skipCount = (request.PageIndex - 1) * request.PageSize; linq2 = skipCount == 0 ? linq2.Take(request.PageSize) : linq2.Skip(skipCount).Take(request.PageSize); var vo = from l in linq2.ToList() select new ProductViewModel().FromEntity <ProductViewModel>(l.P, p => { p.StoreName = l.S.Name; p.TagName = l.T.Name; p.BrandName = l.B.Name; p.CreateUserName = l.C.Nickname; p.PromotionName = from pro in l.Pro select pro.Pro.Name; p.PromotionIds = string.Join(",", (from pro in l.Pro select pro.Pro.Id.ToString()).ToArray()); p.TopicName = from top in l.Spe select top.Spe.Name; p.TopicIds = string.Join(",", (from top in l.Spe select top.Spe.Id.ToString()).ToArray()); p.Resources = l.R.Select(r => new ResourceViewModel().FromEntity <ResourceViewModel>(r)); }); var v = new ProductCollectionViewModel(request, totalCount) { Products = vo.ToList() }; ViewBag.SearchOptions = search; return(View(v)); }
public ActionResult Post([FromBody] ProductCollectionViewModel productRequestVM) { var productCollectionVM = this.productCollectionService.Create(productRequestVM); return(Ok(BaseResponse <ProductCollectionViewModel> .PrepareDataSuccess(productCollectionVM, "Create a artist successful!"))); }
public ProductPeekListPresenter(GridView gridView, ProductCollectionViewModel viewModel) : base(gridView, viewModel) { }