Пример #1
0
        protected void btnPublishAndUnpublish_Click(object sender, EventArgs e)
        {
            NietoYostenDbDataContext db = new NietoYostenDbDataContext();
            int sectionId = int.Parse(ddlSection.SelectedValue);

            var q =
                from a in db.Articles
                where a.SectionId == sectionId
                select a;

            int i = 0;
            foreach (Article a in q)
            {
                CheckBox chk = (CheckBox)rptArticles.Items[i].FindControl(String.Format("chkArticle{0}", a.ArticleId));
                if (chk != null && chk.Checked)
                {
                    a.Published = ((Button)sender).ID == "btnPublish" ? true : false;
                    // Update search index
                    MyLucene.UpdateArticle(a);
                }
                i++;
            }
            db.SubmitChanges();
            rptArticles.DataBind();
        }
Пример #2
0
        public static string GetUserNameFromFbUid(NietoYostenDbDataContext db, string fbUserId)
        {
            var userNameQuery = from u in db.aspnet_Users
                                join fbu in db.FacebookUserIds on u.UserId equals fbu.UserId
                                where fbu.FbUid == fbUserId
                                select u.UserName;

            return userNameQuery.FirstOrDefault();
        }
Пример #3
0
 void UpdateGrid()
 {
     NietoYostenDbDataContext db = new NietoYostenDbDataContext();
     var q =
             from m in db.aspnet_Memberships
             where m.IsApproved == false
             select new { UserName = m.aspnet_User.UserName, m.Email };
     PendingUsersGrid.DataSource = q;
     PendingUsersGrid.DataBind();
 }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // Populate list of sections
     if (!IsPostBack)
     {
         NietoYostenDbDataContext db = new NietoYostenDbDataContext();
         db.Log = new DebugTextWriter();
         PopulateSectionsList(db, ddlSection, 0, null);
     }
     rptArticles.DataSource = articlesDataSource;
     rptArticles.DataBind();
 }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            NietoYostenDbDataContext db = new NietoYostenDbDataContext();
            if (!IsPostBack)
            {
                // Populate Section lists
                admin.AdminSiteContent.PopulateSectionsList(db, ddlSection1, 0, null);
                admin.AdminSiteContent.PopulateSectionsList(db, ddlSection2, 0, null);
                admin.AdminSiteContent.PopulateSectionsList(db, ddlSection3, 0, null);
                admin.AdminSiteContent.PopulateSectionsList(db, ddlSection4, 0, null);

                LoadDataFromDb(db);
            }
        }
Пример #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         NietoYostenDbDataContext db = new NietoYostenDbDataContext();
         int articleId = int.Parse(Page.RouteData.Values["ArticleId"].ToString());
         Article article = db.Articles.Single(a => a.ArticleId == articleId);
         // Populate section list
         admin.AdminSiteContent.PopulateSectionsList(db, ddlSection, 0, null);
         ddlSection.SelectedValue = article.SectionId.ToString();
         txtTitle.Text = article.Title;
         introEditor.Text = article.IntroText;
         contentEditor.Text = article.Content;
     }
 }
Пример #7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            NietoYostenDbDataContext db = new NietoYostenDbDataContext();
            MembershipUser user = Membership.GetUser();
            int articleId = int.Parse(Page.RouteData.Values["ArticleId"].ToString());
            Article article = db.Articles.Single(a => a.ArticleId == articleId);
            article.Title = txtTitle.Text;
            article.IntroText = introEditor.Text;
            article.Content = contentEditor.Text;
            article.SectionId = int.Parse(ddlSection.SelectedValue);
            article.ModifiedBy = (Guid)user.ProviderUserKey;
            article.DateModified = DateTime.Now;
            db.SubmitChanges();
            // Update index
            MyLucene.UpdateArticle(article);

            Response.Redirect("~/admin/AdminSiteContent.aspx");
        }
Пример #8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            NietoYostenDbDataContext db = new NietoYostenDbDataContext();

            var q =
                from h in db.HomePageArticles
                orderby h.Position
                where h.Position >= 1 && h.Position <=4
                select h;

            int i = 1;
            foreach (var hpa in q)
            {
                GetDataFromRow((HomePageArticle)hpa, i);
                i++;
            }
            db.SubmitChanges();
            Response.Redirect("~/admin/AdminSiteContent.aspx");
        }
Пример #9
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     // Insert the article into the DB
     NietoYostenDbDataContext db = new NietoYostenDbDataContext();
     db.Log = new DebugTextWriter();
     MembershipUser user = Membership.GetUser();
     Article article = new Article
     {
         Title = HttpUtility.HtmlEncode(txtTitle.Text),
         IntroText = introEditor.Text,
         Content = contentEditor.Text,
         SectionId = int.Parse(ddlSection.SelectedValue),
         CreatedBy = (Guid)user.ProviderUserKey,
         DateCreated = DateTime.Now
     };
     db.Articles.InsertOnSubmit(article);
     db.SubmitChanges();
     MyLucene.UpdateArticle(article);
     Response.Redirect("~/Admin/AdminSiteContent.aspx");
 }
Пример #10
0
 public static void PopulateSectionsList(NietoYostenDbDataContext db, DropDownList ddl, int level, int? parent)
 {
     List<Section> sectionList;
     if (parent == null)
     {
         sectionList = db.Sections.Where(section => section.ParentSectionId == null).ToList();
     }
     else
     {
         sectionList = db.Sections.Where(section => section.ParentSectionId == parent).ToList();
     }
     foreach (Section section in sectionList)
     {
         string sectionName = new StringBuilder().Insert(0, "&nbsp; ", level * 2).ToString() +
             HttpUtility.HtmlEncode(section.Name);
         ListItem item = new ListItem(HttpUtility.HtmlDecode(sectionName), section.SectionId.ToString());
         ddl.Items.Add(item);
         PopulateSectionsList(db, ddl, level + 1, section.SectionId);
     }
 }
Пример #11
0
        public static void DeletePicture(NietoYostenDbDataContext db, HttpServerUtility server, int pictureId)
        {
            var picture = db.Pictures.SingleOrDefault(p => p.Id == pictureId);
            string folderName = picture.Album.FolderName;
            string fileName = picture.FileName;

            // Delete pictures from file system
            string originalPicFile = server.MapPath(string.Format(
                       "~/pictures/original/{0}/{1}", folderName, fileName));
            System.IO.File.Delete(originalPicFile);

            string webPicFile = server.MapPath(string.Format(
                "~/pictures/web/{0}/{1}", folderName, fileName));
            System.IO.File.Delete(webPicFile);

            string thumbPicFile = server.MapPath(string.Format(
                "~/pictures/thumb/{0}/{1}", folderName, fileName));
            System.IO.File.Delete(thumbPicFile);

            // Delete picture from DB
            db.Pictures.DeleteOnSubmit(picture);
        }
Пример #12
0
 void PopulateArticleList(NietoYostenDbDataContext db, int row)
 {
     Control mainContent = Page.Master.FindControl("MainContent");
     DropDownList ddl = (DropDownList)mainContent.FindControl("ddlArticle" + row);
     DropDownList ddlSection = (DropDownList)mainContent.FindControl("ddlSection" + row);
     int sectionId = int.Parse(ddlSection.SelectedValue);
     PopulateArticleList(db, ddl, sectionId);
 }
Пример #13
0
        void PopulateArticleList(NietoYostenDbDataContext db, DropDownList ddl, int sectionId)
        {
            Table<Article> Article = db.GetTable<Article>();
            var q =
                from a in Article
                where a.SectionId == sectionId
                orderby a.DateCreated descending
                select a;

            ddl.Items.Clear();

            foreach (var article in q)
            {
                string publishedStatus = article.Published ? "" : "(Unpublished)";
                ListItem item = new ListItem(article.Title + " " + publishedStatus,
                    article.ArticleId.ToString());
                ddl.Items.Add(item);
            }
        }
Пример #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     NietoYostenDbDataContext db = new NietoYostenDbDataContext();
     admin.AdminSiteContent.PopulateSectionsList(db, ddlSection, 0, null);
 }
Пример #15
0
 void PopulateRow(NietoYostenDbDataContext db, int row)
 {
     Table<HomePageArticle> HomePageArticles = db.GetTable<HomePageArticle>();
     HomePageArticle h = HomePageArticles.Single(q => q.Position == row);
     Control mainContent = Page.Master.FindControl("MainContent");
     ((CheckBox)mainContent.FindControl("chkShow" + row)).Checked = h.Enabled;
     int sectionId1 = h.Article.SectionId;
     ((DropDownList)mainContent.FindControl("ddlSection" + row)).SelectedValue = sectionId1.ToString();
     DropDownList ddlArticle = (DropDownList)mainContent.FindControl("ddlArticle" + row);
     PopulateArticleList(db, ddlArticle, sectionId1);
     ddlArticle.SelectedValue = h.ArticleId.ToString();
 }
Пример #16
0
 protected void ddlSection4_SelectedIndexChanged(object sender, EventArgs e)
 {
     NietoYostenDbDataContext db = new NietoYostenDbDataContext();
     PopulateArticleList(db, 4);
 }
Пример #17
0
 /// <summary>
 /// Loads data from the DB into the controls
 /// </summary>
 /// <param name="db"></param>
 void LoadDataFromDb(NietoYostenDbDataContext db)
 {
     for (int i = 1; i <= 4; i++)
     {
         PopulateRow(db, i);
     }
 }