public EditProductCategoryDTO GetDataForEdit(int productCategoryId) { // Get product category without tracking by EF IQueryInclude queryObj = new QueryInclude { IsTracking = false }; var entity = _unitOfWork.ProductCategoryRepository.GetById(productCategoryId, queryObj); if (entity == null) { return(null); } EditProductCategoryDTO dto = _mapper.Map <ProductCategory, EditProductCategoryDTO>(entity); if (dto == null) { return(null); } // Get all parent categories that does not contain the editing product catetory dto.ParentCategories = GetFullTree(productCategoryId); return(dto); }
public EditProductCategoryDTO GetDataForCreate(int?parentProductCategoryId) { var dto = new EditProductCategoryDTO { ParentId = parentProductCategoryId }; dto.ParentCategories = GetFullTree(null); return(dto); }
public IActionResult Update(int id) { EditProductCategoryDTO dto = _appService.GetDataForEdit(id); if (dto == null) { return(BadRequest()); } EditProductCategoryViewModel viewModel = _mapper.Map <EditProductCategoryDTO, EditProductCategoryViewModel>(dto); if (viewModel == null) { return(BadRequest()); } return(PartialView("_EditingFormPartial", viewModel)); }
public IActionResult Create(int?parentId) { if (!ModelState.IsValid) { return(BadRequest()); } EditProductCategoryDTO dto = _appService.GetDataForCreate(parentId); if (dto == null) { return(BadRequest()); } EditProductCategoryViewModel viewModel = _mapper.Map <EditProductCategoryDTO, EditProductCategoryViewModel>(dto); if (viewModel == null) { return(BadRequest()); } return(PartialView("_EditingFormPartial", viewModel)); }