Example #1
0
        private void SetVideo(long videoId)
        {
            if ((videoId > 0) && (this.bcApi != null))
            {
                this.video    = this.bcApi.FindVideoById(videoId, Util.VideoWriteFields);
                this.video.id = videoId;
            }

            if (this.video == null)
            {
                this.video = new BCVideo();
            }

            if (this.IsAdmin && this.IsPostBack)
            {
                this.video                  = new BCVideo();
                this.video.id               = videoId;
                this.video.name             = Request.Form["name"];
                this.video.shortDescription = Request.Form["shortDesc"];
                this.video.longDescription  = Request.Form["longDesc"];

                if (Request.Form["isActive"] == "Yes")
                {
                    this.video.itemState = ItemStateEnum.ACTIVE;
                }
                else if (Request.Form["isActive"] == "No")
                {
                    this.video.itemState = ItemStateEnum.INACTIVE;
                }

                this.video.linkURL       = Request.Form["linkUrl"];
                this.video.linkText      = Request.Form["linkText"];
                this.video.videoStillURL = Request.Form["videoStillUrl"];
                this.video.thumbnailURL  = Request.Form["thumbnailUrl"];
                this.video.referenceId   = Request.Form["referenceId"];
                try { this.video.startDate = BCVideo.DateToUnix(DateTime.Parse(Request.Form["startDate"])); } catch { }
                try { this.video.endDate = BCVideo.DateToUnix(DateTime.Parse(Request.Form["endDate"])); } catch { }

                // Validate start and end dates
                if (!string.IsNullOrEmpty(this.video.startDate) && !string.IsNullOrEmpty(this.video.endDate))
                {
                    if (long.Parse(this.video.startDate) > long.Parse(this.video.endDate))
                    {
                        // Notify user of the validatioin error
                        // TBD
                    }
                }

                // Economics
                if (Request.Form["economics"] == BCVideoEconomics.AD_SUPPORTED.ToString())
                {
                    this.video.economics = BCVideoEconomics.AD_SUPPORTED;
                }
                else if (Request.Form["economics"] == BCVideoEconomics.FREE.ToString())
                {
                    this.video.economics = BCVideoEconomics.FREE;
                }

                // Custom Fields
                if (!string.IsNullOrEmpty(Request.Form["customFields"]))
                {
                    string[] list = Request.Form["customFields"].Split(",".ToCharArray());

                    if (this.video.customFields == null)
                    {
                        this.video.customFields = new CustomFields();
                    }
                    else
                    {
                        this.video.customFields.Values.Clear();
                    }

                    foreach (string item in list)
                    {
                        string[] pair = item.Split(":".ToCharArray());
                        string   key  = pair[0].Trim();

                        if (!key.Equals(string.Empty))
                        {
                            this.video.customFields.Values.Add(key, pair[1].Trim());
                        }
                    }
                }

                // Tags
                if (this.video.tags == null)
                {
                    this.video.tags = new BCCollection <string>();
                }
                else
                {
                    this.video.tags.Clear();
                }

                if (!string.IsNullOrEmpty(Request.Form["tags"]))
                {
                    string[] list = Request.Form["tags"].Split(",".ToCharArray());

                    foreach (string item in list)
                    {
                        if (!item.Equals(string.Empty))
                        {
                            this.video.tags.Add(item.Trim());
                        }
                    }
                }
            }
        }