Example #1
0
        public void Save(SavePostRequestModel request)
        {
            string sQuery = "INSERT INTO Posts VALUES(GETDATE(),GETDATE(),0, @Title, @text, @UserId); SELECT CAST(SCOPE_IDENTITY() as int)";
            var    id     = sqlGateway.QueryFirst <int>(sQuery, request);

            foreach (var item in request.CategorieIds)
            {
                string queryForCategories = "INSERT INTO CategoriesPosts(CategoryId,PostId) VALUES(@categoryId, @postId)";
                sqlGateway.Execute(queryForCategories, new { @categoryId = item, @postId = id });
            }
        }
Example #2
0
 public ActionResult Get(SavePostRequestModel requestModel)
 {
     try
     {
         postRepository.Save(requestModel);
         return(Ok("Kaydedildi."));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }