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