コード例 #1
0
        public static List <carrot_CalendarEventCategory> GetCalendarCategories(Guid siteID)
        {
            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                if (!db.carrot_CalendarEventCategories.Where(x => x.SiteID == siteID).Any())
                {
                    carrot_CalendarEventCategory itm = new carrot_CalendarEventCategory();

                    itm = new carrot_CalendarEventCategory();
                    itm.CalendarEventCategoryID = Guid.NewGuid();
                    itm.SiteID = siteID;

                    itm.CategoryName    = "Default";
                    itm.CategoryFGColor = HEX_Black;
                    itm.CategoryBGColor = HEX_White;

                    db.carrot_CalendarEventCategories.InsertOnSubmit(itm);

                    db.SubmitChanges();
                }

                return((from c in db.carrot_CalendarEventCategories
                        orderby c.CategoryName
                        where c.SiteID == siteID
                        select c).ToList());
            }
        }
コード例 #2
0
        protected void btnSaveButton_Click(object sender, EventArgs e)
        {
            bool bAdd = false;

            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                var itm = (from c in db.carrot_CalendarEventCategories
                           where c.CalendarEventCategoryID == ItemGuid
                           select c).FirstOrDefault();

                if (itm == null)
                {
                    bAdd     = true;
                    ItemGuid = Guid.NewGuid();
                    itm      = new carrot_CalendarEventCategory();
                    itm.CalendarEventCategoryID = ItemGuid;
                    itm.SiteID = SiteID;
                }

                itm.CategoryName    = txtCategoryName.Text;
                itm.CategoryFGColor = ddlFGColor.SelectedValue;
                itm.CategoryBGColor = ddlBGColor.SelectedValue;

                if (bAdd)
                {
                    db.carrot_CalendarEventCategories.InsertOnSubmit(itm);
                }

                db.SubmitChanges();
            }

            Response.Redirect(CreateLink(ModuleName, String.Format("id={0}", ItemGuid)));
        }