public ActionResult InsertArticle(Articles article, string userId) { if(ModelState.IsValid) { var id = User.Identity.GetUserId(); if(_articlesRepository.InsertArticle(article, id)) { return RedirectToAction("Index", "Articles"); } } return View(); }
public bool InsertArticle(Articles article, string userId) { var a = new DynamicParameters(); a.Add("UserId", userId); a.Add("Title", article.Title); a.Add("Description", article.Description); a.Add("TagsId", article.TagsId); a.Add("ArticleUrl", article.ArticleUrl); a.Add("ImageUrl", article.ImageUrl); a.Add("Featured", article.Featured); a.Add("Likes", article.Likes); a.Add("Dislike", article.Dislikes); a.Add("IsApproved", article.IsApproved); return _dbConnection.Connection.Execute("Articles_InsertArticle", a, commandType: CommandType.StoredProcedure) > 0; }