protected void Page_Load(object sender, EventArgs e) { var id = Request["ID"]; var idNull = string.IsNullOrEmpty(id); var item = new Promoted() { RowId = Guid.NewGuid() }; using (var con = DAL.con()) { if (!idNull) { item = PromotedDal.SelectById(Convert.ToInt32(id)); } add.Item = item; } }
public Media(dynamic input) { try { OriginalObject = input; Enum.TryParse(input.type, true, out MediaType mediaType); MediaKey = input.media_key; Type = mediaType; Height = input.height; Width = input.width; if (Helpers.HasProperty(input, "duration_ms")) { Duration = input.duration_ms; } if (Helpers.HasProperty(input, "preview_image_url")) { PreviewImageUrl = new Uri(input.preview_image_url); } if (Helpers.HasProperty(input, "non_public_metrics")) { NonPublicMetrics = new NonPublic(input.non_public_metrics); } if (Helpers.HasProperty(input, "organic_metrics")) { OrganicMetrics = new Organic(input.organic_metrics); } if (Helpers.HasProperty(input, "promoted_metrics")) { PromotedMetrics = new Promoted(input.promoted_metrics); } } catch { // any missing properties that are not on the input object // and not caught with Helpers.HasProperty if statement, // do not fail (for now) } }
public Tweet(dynamic input) { try { OriginalObject = input; Id = input.id; Text = input.text; AuthorId = input.author_id; ConversationId = input.conversation_id; CreatedAt = input.created_at; Entities = BaseEntity.GetEntities(input.entities); InReplyToUserId = input.in_reply_to_user_id; Language = input.lang; PossiblySensitive = input.possibly_sensitive; PublicMetrics = new Metrics.Public(input.public_metrics); Source = input.source; if (Helpers.HasProperty(input, "attachments")) { Attachments = new Attachments(input.attachments); } if (Helpers.HasProperty(input, "geo")) { Geo = input.geo; OriginalObject = input; } if (Helpers.HasProperty(input, "reply_settings")) { ReplySettings = Helpers.ToTitleCase(input.reply_settings); } if (Helpers.HasProperty(input, "withheld")) { Withheld = new WithheldContent(input.withheld); } if (Helpers.HasProperty(input, "referenced_tweets")) { List <ReferencedTweet> referencedTweets = new List <ReferencedTweet>(); foreach (dynamic refTweet in input.referenced_tweets) { referencedTweets.Add(new ReferencedTweet(refTweet)); } ReferencedTweets = referencedTweets; } if (Helpers.HasProperty(input, "context_annotations")) { List <Context.ContextAnnotation> contextAnnotations = new List <Context.ContextAnnotation>(); } if (Helpers.HasProperty(input, "non_public_metrics")) { NonPublicMetrics = new NonPublic(input.non_public_metrics); } if (Helpers.HasProperty(input, "organic_metrics")) { OrganicMetrics = new Organic(input.organic_metrics); } if (Helpers.HasProperty(input, "promoted_metrics")) { PromotedMetrics = new Promoted(input.promoted_metrics); } } catch { // any missing properties that are not on the input object // and not caught with Helpers.HasProperty if statement, // do not fail (for now) } }