public async Task <IResult> Add(ArticleForAddUpdateDto dto) { var isExistsArticle = await _articleDal.GetAsync(a => a.Name == dto.Name); if (isExistsArticle != null) { return(new ErrorResult(Messages.ArticleNameAlreadyExist)); } await _articleDal.AddAsync(dto.Map <Article>()); return(new SuccessResult(Messages.AddedSuccessfully)); }
public async Task <Entities.Concrete.Article> AddArticle(ArticleAddForDto articleAddForDto) { var article = _mapper.Map <Article.Entities.Concrete.Article>(articleAddForDto); var articleValidator = new ArticleValidator(); var resutltValidator = articleValidator.Validate(article); if (resutltValidator.Errors.Count > 0) { throw new ValidationException(resutltValidator.Errors); } var addedArticle = await _articleDal.AddAsync(article); return(addedArticle); }
public async Task <IResult> AddAsync(Article entity, IFormFile file) { IResult result = BusinessRules.Run(await ArticleAlreadyExists(entity.Title)); if (result != null) { return(result); } entity.Picture = Guid.NewGuid() + Path.GetExtension(file.FileName); await ImageProcessHelper.UploadAsync(entity.Picture, FolderDirectories.ArticleFolder, file); entity.Title = StringHelper.TitleToPascalCase(entity.Title); entity.Url = StringHelper.FriendlyUrl(entity.Title); await _articleDal.AddAsync(entity); return(new SuccessResult()); }
public Task <Article> AddAsync(Article article) { return(_articleDal.AddAsync(article)); }
public async Task <IResult> AddAsync(Article entity) { await _articleDal.AddAsync(entity); return(new SuccessResult()); }
public async Task <IActionResult> AddAsync(Article article) { await _articleDal.AddAsync(article); return(NoContent()); }