public ActionResult ProcessArticle(int ARTICLE_ID, int ISLEM) { try { IDatabase2 db = DatabaseFactory.GetDbObject(DbSettings.TransactionMode); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.TableName = "article"; gen.AddDataParameter("ACTIVE", ISLEM); gen.FilterText = "where ID=:p1"; gen.AddFilterParameter("p1", ARTICLE_ID); db.ExecuteQuery(gen.GetUpdateCommand()); db.Commit(); return(RedirectToAction("ManageArticle")); } catch { return(RedirectToAction("ManageArticle")); } }
public ActionResult Process(string ID, int ISLEM) { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.TableName = "comment"; if (ISLEM == 1) { gen.AddDataParameter("APPROVED", 1); } else { gen.AddDataParameter("APPROVED", 2); } gen.FilterText = " WHERE ID=:p1"; gen.AddFilterParameter("p1", ID); db.ExecuteQuery(gen.GetUpdateCommand()); List <Comment> cList = ProcessView(); return(View("Index", cList)); }
private static List <Category> GetCategory() { IDatabase2 db = DatabaseFactory.GetDbObject(); List <Category> aList = db.GetObjectList <Category>( "select c.*, (select count(*) from article a, article_category ac where a.id = ac.article_id and a.ACTIVE=1 and ac.category_id = c.id) ARTICLE_COUNT from category c order by LABEL_TEXT"); return(aList); }
private static List <Category> GetData() { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "select * from category order by LABEL_TEXT"; return(db.GetObjectList <Category>(gen.GetSelectCommandBasic())); }
private static List <Article> GetData() { IDatabase2 db = DatabaseFactory.GetDbObject(); List <Article> aList = db.GetObjectList <Article>("select a.*, (select count(*) from comment c where c.article_id = a.id and c.APPROVED = 1) COMMENT_COUNT from article a where ACTIVE=1 order by INSERT_DATE desc"); FillCategory(db, aList); return(aList); }
private List <Article> GetAllData() { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "select * from article order by INSERT_DATE desc"; List <Article> sonuc = db.GetObjectList <Article>(gen.GetSelectCommandBasic()); return(sonuc); }
public ActionResult AddArticle(string TITLE, string CONTENT, int[] CATEGORIES) { try { string nGuid = Guid.NewGuid().ToString("N"); IDatabase2 db = DatabaseFactory.GetDbObject(DbSettings.TransactionMode); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.TableName = "article"; gen.AddDataParameter("TITLE", TITLE); gen.AddDataParameter("TEXT", CONTENT); gen.AddDataParameter("INSERT_DATE", DateTime.Now); gen.AddDataParameter("AUTHOR", "vyigity"); gen.AddDataParameter("ID_GUID", nGuid); db.ExecuteQuery(gen.GetInsertCommand()); IQueryGenerator gen2 = QueryGeneratorFactory.GetDbObject(); gen2.SelectText = "select ID from article where "; gen2.FilterText = "ID_GUID = :p1"; gen2.AddFilterParameter("p1", nGuid); if (CATEGORIES != null && CATEGORIES.Length > 0) { int id = Util.GetProperty <int>(db.GetSingleValue(gen2.GetSelectCommandBasic())); foreach (int i in CATEGORIES) { IQueryGenerator gen3 = QueryGeneratorFactory.GetDbObject(); gen3.TableName = "article_category"; gen3.AddDataParameter("ARTICLE_ID", id); gen3.AddDataParameter("CATEGORY_ID", i); db.ExecuteQuery(gen3.GetInsertCommand()); } } db.Commit(); ProcessView(); return(RedirectToAction("ManageArticle")); } catch { return(RedirectToAction("Index")); } }
private static void FillComments(IDatabase2 db, Article article) { IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "select * from blog.comment c where c.APPROVED = 1 and "; gen.FilterText = "c.article_id = :p1 "; gen.SelectTail = "order by c.INSERT_DATE desc"; gen.AddFilterParameter("p1", article.ID); List <Comment> cList = db.GetObjectList <Comment>(gen.GetSelectCommandBasic()); article.COMMENTS = cList; }
private Article GetData(int id) { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "select * from article where "; gen.FilterText = "id=:p1"; gen.AddFilterParameter("p1", id); Article sonuc = db.GetObject <Article>(gen.GetSelectCommandBasic()); return(sonuc); }
public ActionResult AddCategory(Category param) { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.TableName = "category"; gen.AddDataParameter("LABEL_TEXT", param.LABEL_TEXT); db.ExecuteQuery(gen.GetInsertCommand()); List <Category> cList = ProcessView(); return(View("Index", cList)); }
private static List <Category> GetLoadedCategory(int id) { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "select c.* from category c, article_category ac where "; gen.FilterText = "c.id = ac.category_id and ac.article_id = :p1 "; gen.SelectTail = "order by c.LABEL_TEXT"; gen.AddFilterParameter("p1", id); List <Category> aList = db.GetObjectList <Category>(gen.GetSelectCommandBasic()); return(aList); }
private static List <Article> GetData(string searchText) { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "select a.*,(select count(*) from comment c where c.article_id = a.id and c.APPROVED = 1) COMMENT_COUNT from article a where a.ACTIVE=1 and "; gen.FilterText = "TEXT like CONCAT('%',:p1,'%') "; gen.SelectTail = "order by INSERT_DATE desc"; gen.AddFilterParameter("p1", searchText); List <Article> aList = db.GetObjectList <Article>(gen.GetSelectCommandBasic()); FillCategory(db, aList); return(aList); }
private static List <Comment> GetData() { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = @"select c.*, a.TITLE ARTICLE_TITLE from blog.comment c, blog.article a where c.ARTICLE_ID = a.ID and c.APPROVED = 0 order by INSERT_DATE desc"; return(db.GetObjectList <Comment>(gen.GetSelectCommandBasic())); }
private static List <Article> GetDataWithCategory(int id) { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "select a.*, (select count(*) from comment co where co.article_id = a.id and co.APPROVED = 1) COMMENT_COUNT from article a, article_category c where a.id = c.article_id and a.ACTIVE=1 and "; gen.FilterText = "c.category_id = :p1 order by a. INSERT_DATE desc"; gen.AddFilterParameter("p1", id); List <Article> aList = db.GetObjectList <Article>(gen.GetSelectCommandBasic()); FillCategory(db, aList); return(aList); }
private static void FillCategory(IDatabase2 db, List <Article> aList) { foreach (var arc in aList) { IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "select * from category c ,article_category a where "; gen.FilterText = "a.category_id = c.id and a.article_id = :p1"; gen.SelectTail = "order by c.LABEL_TEXT"; gen.AddFilterParameter("p1", arc.ID); List <Category> cList = db.GetObjectList <Category>(gen.GetSelectCommandBasic()); arc.CATEGORIES = cList; } }
public ActionResult AddComment(Comment param) { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.TableName = "comment"; gen.AddDataParameter("ID", Guid.NewGuid().ToString("N")); gen.AddDataParameter("ARTICLE_ID", param.ARTICLE_ID); gen.AddDataParameter("COMMENT_TEXT", param.COMMENT_TEXT); gen.AddDataParameter("USER_NAME", param.USER_NAME); gen.AddDataParameter("INSERT_DATE", DateTime.Now); db.ExecuteQuery(gen.GetInsertCommand()); return(Json(new { })); }
public ActionResult DeleteCategory(int ID) { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "delete from category where "; gen.FilterText = "id = :p1"; gen.AddFilterParameter("p1", ID); db.ExecuteQuery(gen.GetSelectCommandBasic()); List <Category> cList = ProcessView(); return(View("Index", cList)); }
private static List <Article> GetData(int id) { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "select a.*, (select count(*) from comment c where c.article_id = a.id and c.APPROVED = 1) COMMENT_COUNT from article a where a.ACTIVE=1 and "; gen.FilterText = "a.id = :p1"; gen.AddFilterParameter("p1", id); List <Article> aList = db.GetObjectList <Article>(gen.GetSelectCommandBasic()); FillCategory(db, aList); FillComments(db, aList.First()); return(aList); }
public ActionResult UpdateArticle(int ARTICLE_ID, string TITLE, string CONTENT, int[] CATEGORIES) { try { IDatabase2 db = DatabaseFactory.GetDbObject(DbSettings.TransactionMode); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.TableName = "article"; gen.AddDataParameter("TITLE", TITLE); gen.AddDataParameter("TEXT", CONTENT); gen.AddDataParameter("UPDATE_DATE", DateTime.Now); gen.AddDataParameter("AUTHOR", "vyigity"); gen.FilterText = " where ID=:p1"; gen.AddFilterParameter("p1", ARTICLE_ID); db.ExecuteQuery(gen.GetUpdateCommand()); db.ExecuteQuery("delete from article_category where article_id = " + ARTICLE_ID); if (CATEGORIES != null && CATEGORIES.Length > 0) { foreach (int i in CATEGORIES) { IQueryGenerator gen3 = QueryGeneratorFactory.GetDbObject(); gen3.TableName = "article_category"; gen3.AddDataParameter("ARTICLE_ID", ARTICLE_ID); gen3.AddDataParameter("CATEGORY_ID", i); db.ExecuteQuery(gen3.GetInsertCommand()); } } db.Commit(); return(RedirectToAction("ManageArticle")); } catch { return(RedirectToAction("ArticleUpdate")); } }
public bool Login(string UserName, string Password) { IDatabase2 db = DatabaseFactory.GetDbObject(); IQueryGenerator gen = QueryGeneratorFactory.GetDbObject(); gen.SelectText = "select count(*) from blog.user where "; gen.FilterText = "USER_NAME = :p1 and PASSWORD = :p2"; gen.AddFilterParameter("p1", UserName); gen.AddFilterParameter("p2", Password); int i = Util.GetProperty <int>(db.GetSingleValue(gen.GetSelectCommandBasic())); if (i > 0) { HttpContext.Current.Session["UserName"] = UserName; return(true); } return(false); }
private static void ControlComments(List <Comment> cList) { IDatabase2 db = DatabaseFactory.GetDbObject(); List <BadWord> bwList = db.GetObjectList <BadWord>("select * from blog.bad_word"); foreach (var item in cList) { item.CAUTION = false; foreach (var bw in bwList) { List <string> strList = item.ARTICLE_TITLE.Split(' ').ToList(); strList.AddRange(item.COMMENT_TEXT.Split(' ').ToList()); foreach (string s in strList) { if (s.StartsWith(bw.WORD, StringComparison.CurrentCultureIgnoreCase)) { item.CAUTION = true; } } } } }
private void Form1_Load(object sender, EventArgs e) { db = DatabaseFactory.GetDbObject(); TBConString.Text = db.ConnectionString.ConnectionString; }