Exemple #1
0
 public void InsertOrUpdate(MediaPublished mediaPublished)
 {
     if (mediaPublished.Id == default(int))
     {
         // Existing entity
         //if (mediaPublished.MediaPublishedContext != null)
         //{
         //    // New entity
         //    _ctx.MediaPublishedContexts.Add(mediaPublished.MediaPublishedContext);
         //}
         _ctx.MediaPublisheds.Add(mediaPublished);
     }
     else
     {
         // Existing entity
         //if (mediaPublished.MediaPublishedContext != null)
         //{
         //    if (mediaPublished.MediaPublishedContextId == null || mediaPublished.MediaPublishedContextId == default(int))
         //    {
         //        _ctx.MediaPublishedContexts.Add(mediaPublished.MediaPublishedContext);
         //        _ctx.Entry(mediaPublished).State = EntityState.Modified;
         //    }
         //    else
         //    {
         //        // Existing entity
         //        _ctx.Entry(mediaPublished.MediaPublishedContext).State = EntityState.Modified;
         //        _ctx.Entry(mediaPublished).State = EntityState.Modified;
         //    }
         //}
         //else
         //{
         _ctx.Entry(mediaPublished).State = EntityState.Modified;
         //}
     }
 }
 public static void Run([QueueTrigger("publish-insight")] string queueMessage, TraceWriter log)
 {
     log.Info($"Queue Message: {queueMessage}");
     MediaPublish insightPublish = JsonConvert.DeserializeObject<MediaPublish>(queueMessage);
     if (insightPublish != null)
     {
         MediaPublished insightPublished = MediaClient.PublishInsight(insightPublish);
         log.Info($"Insight Publish: {JsonConvert.SerializeObject(insightPublish)}");
         log.Info($"Insight Published: {JsonConvert.SerializeObject(insightPublished)}");
     }
 }