예제 #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());
                }
            }
        }
예제 #2
0
        public static Get_LoginResult GetToken(string Username, string Password)
        {
            Get_LoginResult Users = new Get_LoginResult();

            if (Username != "" && Password != "")
            {
                using (DijiArticleDataContext db = new DijiArticleDataContext())
                {
                    Users = db.Get_Login(Username, Password).FirstOrDefault();
                }
            }
            return(Users);
        }
예제 #3
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());
                }
            }
        }
예제 #4
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());
                }
            }
        }