private int AddToDatabase(Feed <Google.YouTube.Video> vids, int bikeModelID)
        {
            int entriesAdded = 0;

            foreach (var vid in vids.Entries)
            {
                int?checkVid = Beweb.BewebData.GetValueInt(new Sql("SELECT COUNT(VideoId) FROM Video WHERE VideoCode=", vid.VideoId.Sqlize_Text()));
                if (checkVid > 0)
                {
                    continue;                               // don't add one that already exists
                }
                Models.Video v = new Video();
                v.SourceWebsiteCode = "youtube";                   // actually all are from youtube
                v.VideoCode         = vid.VideoId;
                v.Title             = vid.Title.Left(150);
                v.VideoDescription  = vid.Description;
                v.Credit            = vid.Author;      //vid.Uploader;
                v.ViewCount         = vid.ViewCount;
                v.Status            = "New";
                v.VideoPostedDate   = Convert.ToDateTime(vid.YouTubeEntry.Published);
                v.DateAdded         = DateTime.Now;
                v.ThumbnailUrl      = vid.Thumbnails[0].Url;
                v.BikeModelID       = bikeModelID;
                v.IsAuto            = true;
                v.Save();
                entriesAdded++;
            }
            return(entriesAdded);
        }
Beispiel #2
0
 private void Save(Models.Video record, bool isNew)
 {
     // add any code to update other fields/tables here
     if (isNew)
     {
         record.VideoCode = ParseVideoUrl("YouTube", Request["VideoURL"]);
     }
     record.ThumbnailUrl = "http://i.ytimg.com/vi/" + record.VideoCode + "/default.jpg";
     record.Save();
 }
Beispiel #3
0
        public string ApproveVid()
        {
            int  vid      = Request["VID"].ToInt();
            bool approved = Request["Approved"].ConvertToBool();

            Models.Video v = Models.Video.LoadByVideoID(vid);
            if (approved)
            {
                v.Status = "Approved";
            }
            else
            {
                v.Status = "Rejected";
            }
            v.Save();

            return(vid.ToString());
        }
Beispiel #4
0
        protected ActionResult ProcessForm(Models.Video record)
        {
            try {
                record.UpdateFromRequest();
                Validate(record);
                if (ModelState.IsValid)
                {
                    Save(record, record.IsNewRecord);
                    TempData["info"] = "Video " + record.GetName() + " saved.";
                }
            } catch (UserErrorException e) {
                ModelState.AddModelError("Record", e.Message);
            }

            if (!ModelState.IsValid)
            {
                // invalid so redisplay form with validation message(s)
                return(View("VideoEdit", record));
            }
            else if (Web.Request["SaveAndRefreshButton"] != null)
            {
                return(RedirectToEdit(record.ID));
            }
            else if (Web.Request["DuplicateButton"] != null)
            {
                var newRecord = new Models.Video();
                newRecord.UpdateFrom(record);
                newRecord.Save();
                TempData["info"] = "Copy of Video " + record.GetName() + " created. You are now editing the new copy.";
                return(RedirectToEdit(newRecord.ID));
            }
            else
            {
                return(RedirectToReturnPage());
            }
        }