Пример #1
0
 public bool CreateActivity(string personId, Activity activity, string appId) 
 {
     string title = (activity.title ?? "").Trim();
     if (string.IsNullOrEmpty(title)) 
     {
         throw new Exception("Invalid activity: empty title");
     }
     string body = (activity.body ?? "").Trim();
     var time = UnixTime.ToInt64(DateTime.UtcNow);
     var act = new activity
                   {
                       person_id = int.Parse(personId),
                       app_id = int.Parse(appId),
                       title = title,
                       body = body,
                       created = time
                   };
     db.activities.InsertOnSubmit(act);
     db.SubmitChanges();
     if (db.GetChangeSet().Inserts.Count != 0)
         return false;
 
     var mediaItems = activity.mediaItems;
     if (mediaItems.Count != 0)
     {
         foreach (var mediaItem in mediaItems) 
         {
             var actm = new activity_media_item
                            {
                                activity_id = act.id,
                                media_type = mediaItem.type.ToString().ToLower(),
                                mime_type = mediaItem.mimeType,
                                url = mediaItem.url
                            };
             if (!string.IsNullOrEmpty(actm.mime_type) && 
                 !string.IsNullOrEmpty(actm.url)) 
             {
                 db.activity_media_items.InsertOnSubmit(actm);
                 db.SubmitChanges();
                 if (actm.id == 0) 
                 {
                     return false;
                 }
             } 
             else 
             {
                 return false;
             }
         }
     }
     return true;
 }
Пример #2
0
		private void detach_activity_media_items(activity_media_item entity)
		{
			this.SendPropertyChanging();
			entity.activity = null;
		}
Пример #3
0
 partial void Deleteactivity_media_item(activity_media_item instance);
Пример #4
0
 partial void Updateactivity_media_item(activity_media_item instance);
Пример #5
0
 partial void Insertactivity_media_item(activity_media_item instance);