Example #1
0
        public string UpdateEntry(Entry entry, string username, string password)
        {
            if (SiteSecurity.Login(username, password).Role != "admin")
            {
                throw new Exception("Invalid Password");
            }
            foreach (DayEntry day in data.Days)
            {
                if (day.Date == entry.Created.Date)
                {
                    day.Load();

                    foreach (Entry found in day.Entries)
                    {
                        if (found.EntryId == entry.EntryId)
                        {
                            found.Categories  = entry.Categories;
                            found.Content     = entry.Content;
                            found.Title       = entry.Title;
                            found.Description = entry.Description;
                            found.Modify();

                            day.Save();
                            data.IncrementEntryChange();
                            BlogXUtils.PingWeblogsCom();

                            return(entry.EntryId);
                        }
                    }
                }
            }

            return("not found");
        }
Example #2
0
        private void save_Click(object sender, System.EventArgs e)
        {
            if (SiteSecurity.IsInRole("admin"))
            {
                BlogXData data = new BlogXData();

                bool added = false;

                Entry entry = new Entry();
                entry.Initialize();
                entry.Title       = entryTitle.Text;
                entry.Description = entryAbstract.Text;
                entry.Content     = entryContent.Text;
                entry.Categories  = entryCategories.Text;

                foreach (DayEntry day in data.Days)
                {
                    if (day.Date == entry.Created.Date)
                    {
                        added = true;
                        day.Load();
                        day.Entries.Add(entry);
                        day.Save();
                        data.IncrementEntryChange();
                        BlogXUtils.PingWeblogsCom();
                        break;
                    }
                }
                if (!added)
                {
                    DayEntry newDay = new DayEntry();
                    newDay.Date = entry.Created.Date;
                    newDay.Entries.Add(entry);
                    newDay.Save();

                    data.IncrementEntryChange();
                    BlogXUtils.PingWeblogsCom();
                }

                entryTitle.Text      = "";
                entryAbstract.Text   = "";
                entryContent.Text    = "";
                entryCategories.Text = "";

                Response.Redirect("default.aspx", false);
            }
        }
Example #3
0
        public string CreateEntry(Entry entry, string username, string password)
        {
            if (SiteSecurity.Login(username, password).Role != "admin")
            {
                throw new Exception("Invalid Password");
            }
            bool added = false;

            // ensure that the entryId was filled in
            //
            if (entry.EntryId == null || entry.EntryId.Length == 0)
            {
                entry.EntryId = Guid.NewGuid().ToString();
            }

            foreach (DayEntry day in data.Days)
            {
                if (day.Date == entry.Created.Date)
                {
                    added = true;
                    day.Load();
                    day.Entries.Add(entry);
                    day.Save();
                    data.IncrementEntryChange();
                    BlogXUtils.PingWeblogsCom();
                    break;
                }
            }
            if (!added)
            {
                DayEntry newDay = new DayEntry();
                newDay.Date = entry.Created.Date;
                newDay.Entries.Add(entry);
                newDay.Save();

                data.IncrementEntryChange();
                BlogXUtils.PingWeblogsCom();
            }

            return(entry.EntryId);
        }
Example #4
0
        public void DeleteEntry(string entryId, string username, string password)
        {
            if (SiteSecurity.Login(username, password).Role != "admin")
            {
                throw new Exception("Invalid Password");
            }
            EntryIdCache ecache = new EntryIdCache();

            ecache.Ensure(data);

            DateTime found = new DateTime();

            foreach (EntryIdCacheEntry ece in ecache.Entries)
            {
                if (ece.EntryId == entryId)
                {
                    found = ece.Date;
                    break;
                }
            }

            foreach (DayEntry day in data.Days)
            {
                if (day.Date == found)
                {
                    day.Load();

                    for (int i = 0; i < day.Entries.Count; i++)
                    {
                        if (day.Entries[i].EntryId == entryId)
                        {
                            day.Entries.RemoveAt(i);
                            day.Save();
                            BlogXUtils.PingWeblogsCom();
                            return;
                        }
                    }
                }
            }
        }