public OperationResult Edit(EditProductCategory command) { var operation = new OperationResult(); var productCategory = _productCategoryRepository.Get(command.Id); if (productCategory == null) { return(operation.Failed(ApplicationMessages.RecordNotFound)); } if (_productCategoryRepository.Exist(x => x.Name == command.Name && x.Id != command.Id)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } var slug = command.Slug.Slugify(); var picturePath = $"{"Shop"}/{"ProductCategory"}/{slug}"; var primaryFilename = _fileUploader.Upload(command.PrimaryPicture, picturePath); var secondaryFilename = _fileUploader.Upload(command.SecondaryPicture, picturePath); productCategory.Edit(command.Name, command.Description, primaryFilename, secondaryFilename, command.PictureTitle, command.PictureAlt, command.Keywords, command.MetaDescription, slug); _productCategoryRepository.SaveChanges(); return(operation.Succedded()); }
public void UpdateProductCategory(UpdateProductCategoryInput input) { var productcategory = _ProductCategoryRepository.Get(input.Id); productcategory.CategoryCode = input.CategoryCode; productcategory.CategoryName = input.CategoryName; _ProductCategoryRepository.Update(productcategory); }
public ProductCategoryViewModel EditProductCategory(int id) { var productCategory = _productCategoryRepository.Get(id); var viewModel = new ProductCategoryViewModel { Name = productCategory.Name, Id = productCategory.Id, }; return(viewModel); }
public OperationResult Edit(EditProductCategory command) { OperationResult operationResult = new OperationResult(); ProductCategory productCategory = _repository.Get(command.Id); string sluggish = command.Slug.Slugify(); if (productCategory == null) { return(operationResult.Failed(ApplicationMessages.RecordNotFound)); } if (_repository.Exists(c => c.Name == command.Name && c.Id != command.Id)) { return(operationResult.Failed(ApplicationMessages.DuplicatedRecord)); } productCategory.Edit(command.Name, command.Description, command.Picture, command.PictureAlt, command.PictureTitle, sluggish, command.Keywords, command.MetaDescription); _repository.SaveChanges(); return(operationResult.Succeeded()); }
public void Edit(EditProductCategory command) { var productCategory = _productCategoryRepository.Get(command.Id); if (productCategory != null) { productCategory.Edit(command.Name); _productCategoryRepository.SaveChanges(); } }
public async Task <IEnumerable <ProductView> > Get() { var productCategories = await productCategoryRepository.GetAll(); var list = new List <ProductView>(); foreach (var item in productCategories) { list.Add(await productCategoryRepository.Get(item.ProductId, item.CategoryId)); } return(list); }
public async Task <BaseViewModel <PagingResult <ProductCategoryViewModel> > > GetAllProductCategories(BasePagingRequestViewModel request) { var pageSize = request.PageSize; var pageIndex = request.PageIndex; var result = new BaseViewModel <PagingResult <ProductCategoryViewModel> >(); string filter = SearchHelper <ProductCategory> .GenerateStringExpression(request.Filter, Constants.DEAFAULT_DELETE_STATUS_EXPRESSION); Expression <Func <ProductCategory, bool> > FilterExpression = await LinqHelper <ProductCategory> .StringToExpression(filter); QueryArgs <ProductCategory> queryArgs = new QueryArgs <ProductCategory> { Offset = pageSize * (pageIndex - 1), Limit = pageSize, Filter = FilterExpression, Sort = request.SortBy, }; var data = _repository.Get(queryArgs.Filter, queryArgs.Sort, queryArgs.Offset, queryArgs.Limit).ToList(); if (data == null || !data.Any()) { result.Description = MessageHandler.CustomMessage(MessageConstants.NO_RECORD); result.Code = MessageConstants.NO_RECORD; } else { var pageSizeReturn = pageSize; if (data.Count < pageSize) { pageSizeReturn = data.Count; } result.Data = new PagingResult <ProductCategoryViewModel> { Results = _mapper.Map <IEnumerable <ProductCategoryViewModel> >(data), PageIndex = pageIndex, PageSize = pageSizeReturn, TotalRecords = _repository.Count(queryArgs.Filter) }; } return(result); }
public OperationResult Edit(EditProductCategory command) { var operation = new OperationResult(); var productCategory = repo.Get(command.Id); if (productCategory == null) { return(operation.Failed("رکوردی یافت نشد")); } if (repo.Exist(x => x.Name == command.Name && x.Id != command.Id)) { return(operation.Failed("این نام تکراری است. لطفا نام دیگری انتخاب کنید")); } var slug = command.Slug.Slugify(); productCategory.Edit(command.Name, command.Description, command.Picture, command.PictureAlt, command.PictureTitle, command.Keywords, command.MetaDescription, slug); repo.SaveChange(); return(operation.Succedded("ویرایش اطلاعات با موفقیت انجام شد")); }
public OperationResult Edit(EditProductCategory command) { var operation = new OperationResult(); var productcategory = _iProductCategoryRepository.Get(command.Id); if (productcategory == null) { return(operation.Failed(ApplicationMessages.RecordNotFound)); } if (_iProductCategoryRepository.Exists(x => x.Name == command.Name && x.Id != x.Id)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } var slug = command.Slug.Slugify(); productcategory.Edit(command.Name, command.Description, command.Picture, command.PictureAlt, command.PictureTitle, command.Keywords, command.MetaDescription, slug); _iProductCategoryRepository.Save(); return(operation.Succeeded()); }
public OperationResult Edit(EditProductCategory command) { var operationResult = new OperationResult(); var productCategory = _productCategoryRepository.Get(command.Id); if (productCategory == null) { return(operationResult.Failed("چنین رکوردی در دیتابیس موجود نیست.")); } if (_productCategoryRepository.Exists(p => p.Name == command.Name && p.Id != command.Id)) { return(operationResult.Failed("امکان ثبت رکورد تکراری وجود ندارد.")); } var filename = _fileUploader.FileUpload(command.Picture, command.Slug); productCategory.Edit(command.Name, command.Description, filename, command.PictureAlt, command.PictureTitle, command.Keywords, command.MetaDescription, command.Slug.Slugify()); _productCategoryRepository.SaveChanges(); return(operationResult.Succeeded()); }
public ICollection <ProductCategory> Get(Expression <Func <ProductCategory, bool> > predicate) { return(repository.Get(predicate)); }
public async Task <ProductCategoryDto> Get(int id) { return(await _productCategoryRepository.Get(id)); }
public async Task <ProductCategoryDto> Get(int id) { var entity = await productCategoryRepository.Get(id); return(mapper.Map <ProductCategoryDto>(entity)); }