public async Task <ProductCategoryDto> Create(ProductCategoryCreateOrUpdateDto input) { var entity = input.MapTo <Eron.Core.Entities.Financial.Shop.ProductCategory>(); entity.Slug = entity.Slug.IsPopulated() ? entity.Slug.Slugify() : entity.Title.Slugify(); var result = UnitOfWork.ProductCategoryRepository.Create(entity); await UnitOfWork.SaveAsync(); return(result.MapTo <ProductCategoryDto>()); }
public async Task <ProductCategoryDto> Update(ProductCategoryCreateOrUpdateDto input) { if (!input.IsUpdateEntry()) { throw new EntityNotFoundException(); } var entity = input.MapTo <Eron.Core.Entities.Financial.Shop.ProductCategory>(); UnitOfWork.ProductCategoryRepository.Update(entity); await UnitOfWork.SaveAsync(); return(entity.MapTo <ProductCategoryDto>()); }
public async Task <IHttpActionResult> Put(ProductCategoryCreateOrUpdateDto input) { var result = await _service.Update(input); return(Ok(result)); }