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()); } } }
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); }
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()); } } }
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()); } } }