public OperationResult Edit(EditArticleCategory command) { var operation = new OperationResult(); var articleCategory = _articleCategoryRepository.Get(command.Id); if (articleCategory == null) { return(operation.Failed(ApplicationMessages.RecordNotFound)); } if (_articleCategoryRepository.Exists(x => x.Name == command.Name && x.Id != command.Id)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } var slug = command.Slug.Slugify(); var picturePath = $"{command.Slug}"; var pictureName = _fileUploader.Upload(command.Picture, picturePath); //var pictureName = _fileUploader.Upload(command.Picture, slug); articleCategory.Edit(command.Name, pictureName, command.PictureAlt, command.PictureTtile, command.Description, command.ShowOrder, command.Keywords, slug, command.MetaDescription, command.CanonicalAddress); _articleCategoryRepository.SaveChanges(); return(operation.Succeeded()); }
public OperationResult Edit(EditArticleCategory command) { OperationResult operationResult = new OperationResult(); var ACategory = _articleCategoryRepo.Get(command.id); if (ACategory == null) { return(operationResult.Failed(ApplicationMessage.recordNotFound)); } if (_articleCategoryRepo.Exists(c => c.Name == command.Name && c.Id != command.id)) { return(operationResult.Failed(ApplicationMessage.duplicated)); } var slug = command.Slug.Slugify(); ACategory.Edit(command.Name, command.Description, slug, command.ShowOrder, command.KeyWords, command.MetaDescription, command.CanonicalAddress); _articleCategoryRepo.Save(); return(operationResult.Succeeded()); }
public OperationResult Edit(EditArticleCategory command) { var operation = new OperationResult(); var articleCategory = _articleCategoryRepository.Get(command.Id); if (_articleCategoryRepository == null) { return(operation.Failed(ApplicationMessages.RecordNotFound)); } var slug = command.Slug.Slugify(); var path = $"{"Blog"}/{slug}"; var pictureName = _fileUploader.Upload(command.Picture, path); articleCategory.Edit(command.Name, pictureName, command.PictureAlt, command.PictureTitle, command.ShortDescription, command.Description, command.ShowOrder, slug, command.Keywords, command.MetaDescription, command.CanonicalAddress); _articleCategoryRepository.SaveChanges(); return(operation.Succedded()); }
public JsonResult OnPostEdit(EditArticleCategory command) { var result = _articleCategoryApplication.Edit(command); return(new JsonResult(result)); }