Esempio n. 1
0
        public HttpResponseMessage GetComment([FromBody]  Get_ArticleResult Articleobj)
        {
            var claims = ClaimsPrincipal.Current.Identities.First().Claims;

            try
            {
                List <GetCommentResult> obj = new List <GetCommentResult>();
                using (DijiArticleDataContext db = new DijiArticleDataContext())
                {
                    obj = db.GetComment(Articleobj.ID).ToList();
                    db.AddLog(Convert.ToInt32(claims.First(x => x.Type == "ID").Value), "Comment", "Get", HttpStatusCode.OK.ToString());
                }
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, obj));
            }
            catch (Exception Ex)
            {
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, Ex.Message));

                using (DijiArticleDataContext db = new DijiArticleDataContext())
                {
                    db.AddLog(Convert.ToInt32(claims.First(x => x.Type == "ID").Value), "Comment", "Get",
                              HttpStatusCode.BadRequest.ToString());
                }
            }
        }
Esempio n. 2
0
        public HttpResponseMessage PostArticle([FromBody]  Get_ArticleResult obj)
        {
            var claims = ClaimsPrincipal.Current.Identities.First().Claims;

            try
            {
                using (DijiArticleDataContext db = new DijiArticleDataContext())
                {
                    db.Set_Article(obj.ID, Convert.ToInt32(claims.First(x => x.Type == "ID").Value), obj.ArticleText, obj.ArticleHeader);
                    db.AddLog(Convert.ToInt32(claims.First(x => x.Type == "ID").Value), "Article", "Post", HttpStatusCode.OK.ToString());
                }
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, obj));
            }
            catch (Exception Ex)
            {
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, Ex.Message));

                using (DijiArticleDataContext db = new DijiArticleDataContext())
                {
                    db.AddLog(Convert.ToInt32(claims.First(x => x.Type == "ID").Value), "Article", "Post", HttpStatusCode.BadRequest.ToString());
                }
            }
        }
Esempio n. 3
0
        public HttpResponseMessage DeleteArticle([FromBody] GetCommentResult obj)
        {
            var claims = ClaimsPrincipal.Current.Identities.First().Claims;

            try
            {
                using (DijiArticleDataContext db = new DijiArticleDataContext())
                {
                    db.Delete_Comment(obj.ID);
                    db.AddLog(Convert.ToInt32(claims.First(x => x.Type == "ID").Value), "Comment", "Delete", HttpStatusCode.OK.ToString());
                }
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, obj.ID + " Deleted"));
            }
            catch (Exception Ex)
            {
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, Ex.Message));

                using (DijiArticleDataContext db = new DijiArticleDataContext())
                {
                    db.AddLog(Convert.ToInt32(claims.First(x => x.Type == "ID").Value), "Comment", "Delete",
                              "ID : " + obj.ID + "  " + HttpStatusCode.BadRequest.ToString());
                }
            }
        }