Пример #1
0
 public static VM_Event ByID(long EventID)
 {
     using (exodusEntities exodusDB = new exodusEntities())
     {
         var rez = exodusDB.stp_Event_ByID(EventID).FirstOrDefault();
         if (rez != null)
         {
             var tag = rez.fk_TagID.HasValue ? _DL.Tag.Get.ByID(rez.fk_TagID.Value) : null;
             //
             var _event = new VM_Event()
             {
                 ID       = rez.EventID,
                 Title    = rez.EventTitle,
                 Added    = rez.EventAdded,
                 Category = new VM_EventCategory()
                 {
                     ID = rez.fk_EventCategoryID
                 },
                 Type          = Global.Cache.dicEventTypes[(EN_EventType)rez.fk_EventTypeID],
                 Tag           = tag ?? new VM_Tag(),
                 Application   = (tag == null) ? new VM_Application() : Global.Cache.dicApplications[tag.ApplicationType],
                 ImportanLevel = new VM_ImportanLevel()
                 {
                     ID = (int)Global.Cache.dicEventTypes[(EN_EventType)rez.fk_EventTypeID].ImportantLevel
                 }
             };
             // load XML
             _event.Content.LoadXml(rez.EventContent);
             _event.Thumbnail.LoadXml(rez.EventThumbnail);
             return(_event);
         }
         ;
     }
     return(null);
 }
Пример #2
0
 public static long Event(VM_Event Event)
 {
     using (var exodusDB = new exodusEntities())
     {
         ObjectParameter eventID = new ObjectParameter("EventID", 0);
         //
         exodusDB.stp_Event_Add(
             eventTypeID: Event.Type.ID,
             eventTitle: Event.Title,
             eventContent: Event.Content.OuterXml,
             eventThumbnail: Event.Thumbnail.OuterXml,
             tagID: Event.Tag == null ? new long?() : Event.Tag.TagID,
             applicationID: Event.Application == null ? new int?() : Event.Application.ApplicationID,
             eventID: eventID);
         //
         return(Convert.ToInt64(eventID.Value));
     }
 }