public async Task <IActionResult> AddArticle([FromBody] ViewModelArticle form) { try { bool retval = _uow.Article.AddArticle(form); if (retval == true) { return(Json("Article is added")); } return(Json("Article is not added")); } catch (Exception e) { return(Json("This is a problem: " + e)); } }
public bool AddArticle(ViewModelArticle form) { try { article.CategoryId = form.CategoryId; article.Content = form.Content; article.IsActive = true; article.IsDeleted = false; article.Title = form.Title; article.CreateIpAddress = _accessor.HttpContext.Connection.RemoteIpAddress.ToString(); article.CreatedDateTime = System.DateTime.Now; articleContext.Add(article); articleContext.SaveChanges(); return(true); } catch (System.Exception) { return(false); } }