public ActionResult UpdateCategory(Guid pk, Guid physicalInstanceId, string agency, string name, string value) { try { var client = RepositoryHelper.GetClient(); var category = client.GetLatestItem(pk, agency) as Category; CategoryMapper.UpdateCategoryProperty(category, name, value); category.Version++; var commitOptions = new CommitOptions(); commitOptions.NamedOptions.Add("RegisterOrReplace"); client.RegisterItem(category, commitOptions); using (var db = ApplicationDbContext.Create()) { var file = db.Files.Where(x => x.Id == physicalInstanceId) .FirstOrDefault(); if (file != null) { file.HasPendingMetadataUpdates = true; db.SaveChanges(); } } // For x-editable, just a simple 200 return is sufficient if things went well. return(Content(string.Empty)); } catch (Exception ex) { throw new HttpException(500, ex.Message); } }
public ItemsViewController(IAppBLL bll) { _bll = bll; _brandMapper = new BrandMapper(); _categoryMapper = new CategoryMapper(); _itemMapper = new ItemMapper(); }
public override void Execute(object parameter) { List <Category> categories = DB.CategoryRepository.Get(); List <CategoryModel> categoryModels = new List <CategoryModel>(); CategoryMapper categoryMapper = new CategoryMapper(); for (int i = 0; i < categories.Count; i++) { Category category = categories[i]; CategoryModel categoryModel = categoryMapper.Map(category); categoryModel.No = i + 1; categoryModels.Add(categoryModel); } Enumeration.Enumerate(categoryModels); CategoryViewModel categoryViewModel = new CategoryViewModel(); categoryViewModel.AllCategories = categoryModels; categoryViewModel.Categories = new ObservableCollection <CategoryModel>(categoryModels); CategoriesControl categoriesControl = new CategoriesControl(); categoriesControl.DataContext = categoryViewModel; MainWindow mainWindow = (MainWindow)mainViewModel.Window; mainWindow.GrdCenter.Children.Clear(); mainWindow.GrdCenter.Children.Add(categoriesControl); }
public ServiceAnswer <CategoryDto> GetCategoryById(int categoryId) { using (var uow = _unitOfWorkFactory.Create()) { try { var categoryRepository = _repositoryFactory.CreateCategoryRepository(uow); var receivedCategory = categoryRepository.GetEntityById(categoryId); var categoryDTO = new CategoryDto(); if (receivedCategory != null) { var mapper = new CategoryMapper(); categoryDTO = mapper.MapToCategoryDto(receivedCategory); } return(new ServiceAnswer <CategoryDto>(categoryDTO, AnswerStatus.Successfull)); } catch (Exception exc) { _logger.Log(exc.ToString()); return(new ServiceAnswer <CategoryDto>(null, AnswerStatus.Failed)); } } }
public async Task <CategoryDetailsQueryData> Handle(GetCategoryDetailsQuery request, CancellationToken cancellationToken) { var category = await dbContext.Categories .FirstOrDefaultAsync(cat => cat.Id == request.Id); return(CategoryMapper.FromCategoryToCategoryDetailsQueryData(category)); }
public IActionResult SaveCategory(CategoryModel categoryModel) { if (ModelState.IsValid == false) { return(Content("Model is invalid")); } CategoryMapper mapper = new CategoryMapper(); Category category = mapper.Map(categoryModel); //ERROR: category.Creator = CurrentUser; if (category.Id != 0) { DB.CategoryRepository.Update(category); } else { DB.CategoryRepository.Add(category); } TempData["Message"] = "Saved successfully"; return(RedirectToAction("Index")); }
public SearchPageController(IAppBLL bll) { _bll = bll; _brandMapper = new BrandMapper(); _categoryMapper = new CategoryMapper(); _itemMapper = new ItemMapper(); }
public IList <CategoryModel> GetActiveCategories() { var bucket = GetActiveCategoriesBucket(); var categoriesEntities = _systemRepository.Category.GetAll(bucket); return(CategoryMapper.MapToModels(categoriesEntities)); }
public ReceiptRepository() { receiptMapper = new ReceiptMapper(); productMapper = new ProductMapper(); categoryMapper = new CategoryMapper(); customizedProductService = new CustomizedProductService(); }
public ServiceAnswer <IEnumerable <CategoryDto> > GetBlogCategories(int blogId) { using (var uow = _unitOfWorkFactory.Create()) { try { var categoryRepository = _repositoryFactory.CreateCategoryRepository(uow); var receivedCategories = categoryRepository.GetBlogCategories(blogId); var categoryDTOList = new List <CategoryDto>(); if (receivedCategories != null) { var mapper = new CategoryMapper(); categoryDTOList = mapper.MapToCategoryDtoList(receivedCategories).ToList(); } return(new ServiceAnswer <IEnumerable <CategoryDto> >(categoryDTOList, AnswerStatus.Successfull)); } catch (Exception exc) { _logger.Log(exc.ToString()); return(new ServiceAnswer <IEnumerable <CategoryDto> >(null, AnswerStatus.Failed)); } } }
public Article CreateModel(ArticleDTO articleDto) { var article = _data.CreateModel(articleDto); Category categories = _unitOfWork.CategoryRepository.Find(q => q.Name == articleDto.Category.Name).ToList().FirstOrDefault(); article.Category = categories ?? CategoryMapper.MapCategory(articleDto.Category); return(article); }
public async Task Update(CategoryDto category) { var result = await this.unitOfWork.CategoryRepository.Get(category.Id); CategoryMapper.MapUpdate(result, category); await this.unitOfWork.CategoryRepository.Update(result); }
public IActionResult List() { var categories = categoryRepository.Query().Where(x => !x.IsDeleted).ToList(); var categoriesList = CategoryMapper.ToCategoryListItem(categories); var gridData = categoriesList; return(Json(gridData)); }
public async Task <CategoryDto> AddAsync(int userId, CategoryDto dto) { var model = CategoryMapper.Map(dto); var newModel = await _categoryRepository.AddAsync(userId, model); var result = CategoryDtoMapper.Map(newModel); return(result); }
protected override async Task Handle(AddCategoryCommand request, CancellationToken cancellationToken) { var category = CategoryMapper.FromAddCategoryToCategory(request); category.Image = await imageUploadService.UploadImage(request.Cover); dbContext.Categories.Add(category); await dbContext.SaveChangesAsync(); }
/// <summary> /// Return all categories /// </summary> /// <returns></returns> public IEnumerable <Category> GetAll() { const string cacheKey = "GetAllCategories"; return((IEnumerable <Category>)ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem(cacheKey, () => { return CategoryMapper.MapCategory(_forumRootNode.Descendants(DialogueConfiguration.Instance.DocTypeForumCategory).ToList()); })); }
public override ActionResult Index(RenderModel model) { using (UnitOfWorkManager.NewUnitOfWork()) { // Get the category var category = CategoryMapper.MapCategory(model.Content, true); // Set the page index var pageIndex = AppHelpers.ReturnCurrentPagingNo(); // check the user has permission to this category var permissions = ServiceFactory.PermissionService.GetPermissions(category, _usersRoles); if (!permissions[AppConstants.PermissionDenyAccess].IsTicked) { var topics = ServiceFactory.TopicService.GetPagedTopicsByCategory(pageIndex, Settings.TopicsPerPage, int.MaxValue, category.Id); var isSubscribed = UserIsAuthenticated && (ServiceFactory.CategoryNotificationService.GetByUserAndCategory(CurrentMember, category).Any()); // Create the main view model for the category var viewModel = new ViewCategoryViewModel(model.Content) { Permissions = permissions, Topics = topics, Category = category, PageIndex = pageIndex, TotalCount = topics.TotalCount, User = CurrentMember, IsSubscribed = isSubscribed }; // If there are subcategories then add then with their permissions if (category.SubCategories.Any()) { var subCatViewModel = new CategoryListViewModel { AllPermissionSets = new Dictionary <Category, PermissionSet>() }; foreach (var subCategory in category.SubCategories) { var permissionSet = ServiceFactory.PermissionService.GetPermissions(subCategory, _usersRoles); subCategory.LatestTopic = ServiceFactory.TopicService.GetPagedTopicsByCategory(1, Settings.TopicsPerPage, int.MaxValue, subCategory.Id).FirstOrDefault(); subCategory.TopicCount = ServiceFactory.TopicService.GetTopicCountByCategory(subCategory.Id); subCatViewModel.AllPermissionSets.Add(subCategory, permissionSet); } viewModel.SubCategories = subCatViewModel; } return(View(PathHelper.GetThemeViewPath("Category"), viewModel)); } return(ErrorToHomePage("No Permission")); } }
public async Task CreateAsync(CategoryDTO category) { if (category == null) { throw new ArgumentNullException(nameof(category)); } _unitOfWork.Categories.Create(CategoryMapper.MapToEntity(category)); await _unitOfWork.SaveAsync(); }
public void CalculateOrderDiscount1() { ProductMapper productMapper = new ProductMapper(); Product product = productMapper.FindProductById(this.ProductID); CategoryMapper categoryMapper = new CategoryMapper(); Category category = categoryMapper.FindCategoryById(product.CategoryID); DoDiscountCalculation(this, category); }
public IList <CategoryModel> GetActiveCategories() { var bucket = new RelationPredicateBucket(); bucket.PredicateExpression.Add(CategoryFields.IsDeleted == false); bucket.PredicateExpression.Add(CategoryFields.IsActive == true); var categoriesEntities = _systemRepository.Category.GetAll(bucket); return(CategoryMapper.MapToModels(categoriesEntities)); }
public DataTable getCategoryPickList() { DataTable dt = new DataTable(); MapDataMaper.CategoryMapper categoryMap = new CategoryMapper(); dt = categoryMap.getCategoryPickList(); return(dt); }
public override void PreInitialize() { Configuration.Authorization.Providers.Add <HasinAuthorizationProvider>(); Configuration.Modules.AbpAutoMapper().Configurators.Add(config => { CategoryMapper.CreateMappings(config); ProductMapper.CreateMappings(config); }); }
public async Task <CategoryDTO> GetByIdAsync(int id) { Category res = await _unitOfWork.Categories.GetAsync(id); if (res == null) { return(null); } return(CategoryMapper.MapToDTO(res)); }
public ActionResult EditCategory(MvcCategory category) { if (ModelState.IsValid) { categories.Update(CategoryMapper.GetBLLEntity(category)); return(RedirectToRoute("Categories")); } return(View()); }
public async Task <IActionResult> GetAll() { List <Category> categories = await db.Categories .AsNoTracking() .ToListAsync(); //map to response CategoryGetAllResponse categoryGetAllResponse = CategoryMapper.MapFromCategoriesToCategoryGetAllResponse(categories); return(Ok(categoryGetAllResponse)); }
public async Task <ActionResult <IEnumerable <PublicApi.v1.DTO.CategoryWithProductCount> > > GetCategories(string search, int?pageIndex, int?pageSize) { if ((pageIndex != null && pageIndex < 1) || (pageSize != null && pageSize < 1)) { return(BadRequest()); } var category = (await _bll.Categories.GetAllWithProductCountForShopAsync(User.GetShopId(), search, pageIndex, pageSize)) .Select(e => CategoryMapper.MapFromBLL(e)).ToList(); return(category); }
public async Task <ActionResult <PublicApi.v1.DTO.CategoryWithProductCount> > GetCategory(int id) { var category = await _bll.Categories.GetByIndexAndShop(id, User.GetShopId()); if (category == null) { return(NotFound()); } return(CategoryMapper.MapFromBLL(category)); }
private IEnumerable <MvcCategory> GetAllOrFind(string searchString) { IEnumerable <BLLCategory> allCategories = categories.GetAll(); List <MvcCategory> mvcCategories = allCategories.Select(c => CategoryMapper.GetMVCEntity(c)).ToList(); if (!ReferenceEquals(searchString, null) && searchString != "") { mvcCategories = mvcCategories.Where(s => s.Name.Contains(searchString)).ToList(); } return(mvcCategories); }
public TaskManagement.Api.Models.Category Save(TaskManagement.Api.Models.Category category) { var cat = CategoryMapper.CreateCategory(category); context.tbl_category.Add(cat); context.SaveChanges(); // return the insert element with the right id return(CategoryMapper.CreateCategory(cat)); }
public void TestFindCategoryById() { int categoryId = 6; CategoryMapper categoryMapper = new CategoryMapper(); Category category = categoryMapper.FindCategoryById(6); Assert.AreEqual(categoryId, category.CategoryID); Assert.AreEqual("Meat/Poultry", category.CategoryName); Assert.AreEqual(categoryId.ToString(), category.DomainId); }