コード例 #1
0
 //AddCategoryChildToEventCategory
 private void AddCategoryChildToEventCategory(Event evnt, CategoriesMap cm)
 {
     EventCategory evnt_cat = dataContext.EventCategories.SingleOrDefault(EC => EC.Event_ID == evnt.ID && EC.MainCategory_ID == cm.MainCategory_ID && EC.Category_ID == cm.Category_ID);
       if (evnt_cat == null)
       {
     evnt_cat = new EventCategory();
     dataContext.EventCategories.InsertOnSubmit(evnt_cat);
       }
       evnt_cat.Category_ID = cm.Category_ID;
       evnt_cat.MainCategory_ID = cm.MainCategory_ID;
       evnt_cat.IsActive = true;
       evnt_cat.LastUpdate = DateTime.Now;
       evnt_cat.Owner_ID = AppHelper.CurrentUser.ID;
       evnt_cat.Event_ID = evnt.ID;
       evnt_cat.Descr = cm.FullCategory; //evnt_cat.FullCategory;
       evnt_cat.Priority = cm.Priority;
       evnt.EventCategories.Add(evnt_cat);
 }
コード例 #2
0
        //UpdateEvent
        public bool UpdateEvent(EventForm info)
        {
            Event evnt = (info.ID > 0) ? GetEvent(info.ID) : null;
              bool newEvent = evnt == null;
              bool iscurrent = !newEvent && GetCurrentEvent().ID == info.ID;
              try
              {
            using (TransactionScope ts = new TransactionScope())
            {
              if (newEvent)
              {
            evnt = new Event();
            dataContext.Events.InsertOnSubmit(evnt);
              }
              evnt.BuyerFee = info.BuyerFee;
              evnt.DateEnd = info.DateEnd;
              evnt.DateStart = info.DateStart;
              evnt.Description = info.Description;
              evnt.IsClickable = info.IsClickable;
              evnt.IsCurrent = info.IsCurrent;
              evnt.IsViewable = info.IsViewable;
              evnt.LastUpdate = DateTime.Now;
              evnt.Ordinary = info.Ordinary;
              evnt.Title = info.Title;
              evnt.Type_ID = info.Type_ID;

              if (newEvent)
            GeneralRepository.SubmitChanges(dataContext);
              if (evnt.EventCategories.Count > 0 && !newEvent)
            foreach (EventCategory ec in evnt.EventCategories)
              ec.IsActive = false;

              CategoriesMap cat_map;
              foreach (long index in info.CategoriesList)
              {
            cat_map = dataContext.CategoriesMaps.SingleOrDefault(CM => CM.ID == index);
            if (cat_map != null)
              AddCategoryChildToEventCategory(evnt, cat_map);
              }
              GeneralRepository.SubmitChanges(dataContext);
              if (!newEvent && evnt.CloseStep == 0)
            dataContext.sp_Event_ChangeAuctionStartEnd(evnt.ID);

              ts.Complete();
            }
              }
              catch (ChangeConflictException cce)
              {
            Logger.LogException(cce);
            throw cce;
              }
              catch (Exception ex)
              {
            Logger.LogException(ex);
            throw ex;
              }
              if (iscurrent || GetCurrentEvent().ID == evnt.ID)
              {
            try
            {
              System.Net.WebClient client = new System.Net.WebClient();
              client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
              client.OpenRead(Consts.CacheClearFrontendIP + Consts.FrontEndClearMethod);
            }
            catch (Exception ex)
            {
              Logger.LogException("[" + Consts.CacheClearFrontendIP + Consts.FrontEndClearMethod + "]", ex);
            }
              }
              return true;
        }