public async Task <ResponseArticle> AddArticle(RequestArticle requestCreateArticle) { var article = new Article { Title = requestCreateArticle.Title, Content = requestCreateArticle.Description }; await _unitOfWork.Repository <Article>().Add(article); await _unitOfWork.CommitAsync(); searchKey = $"{searchKey}-{article.Id}"; return(await SetRedis(searchKey, (ResponseArticle)article)); }
public async Task UpdateArticle(int articledId, RequestArticle requestArticle) { var article = await _unitOfWork.Repository <Article>().Find(articledId); if (article == null) { return; } article.Title = requestArticle.Title; article.Content = requestArticle.Description; _unitOfWork.Repository <Article>().Update(article); await _unitOfWork.CommitAsync(); searchKey = $"{searchKey}-{articledId}"; await SetRedis(searchKey, (ResponseArticle)article); }
public IActionResult Put(int articledId, [FromBody] RequestArticle article) { _articleService.UpdateArticle(articledId, article); return(NoContent()); }
public async Task <IActionResult> Post([FromBody] RequestArticle article) { var responseModel = await _articleService.AddArticle(article); return(Created(string.Empty, $"{responseModel.Id}")); }