Esempio n. 1
0
        public ActionResult ProfileDetail(string userName)
        {
            ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 100 : 277;
            ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 225 : 400;

            _ua = new UserAccount(userName);

            var uad = new UserAccountDetail();
            uad.GetUserAccountDeailForUser(_ua.UserAccountID);

            uad.BandsSeen = ContentLinker.InsertBandLinks(uad.BandsSeen, false);
            uad.BandsToSee = ContentLinker.InsertBandLinks(uad.BandsToSee, false);

            var model = new ProfileModel();

            model.ProfilePhotoMainRaw = uad.RawProfilePicUrl;

            if (_ua.UserAccountID > 0)
            {
                model.UserAccountID = _ua.UserAccountID;
                model.PhotoCount = PhotoItems.GetPhotoItemCountForUser(_ua.UserAccountID);
                model.CreateDate = _ua.CreateDate;
            }

            if (_mu != null)
            {
                ViewBag.IsBlocked = BlockedUser.IsBlockedUser(_ua.UserAccountID, Convert.ToInt32(_mu.ProviderUserKey));
                ViewBag.IsBlocking = BlockedUser.IsBlockedUser(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID);

                if (_ua.UserAccountID == Convert.ToInt32(_mu.ProviderUserKey))
                {
                    model.IsViewingSelf = true;
                }
                else
                {
                    var ucon = new UserConnection();

                    ucon.GetUserToUserConnection(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID);

                    model.UserConnectionID = ucon.UserConnectionID;

                    if (BlockedUser.IsBlockedUser(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID))
                    {
                        return RedirectToAction("index", "home");
                    }
                }
            }
            else
            {
                if (uad.MembersOnlyProfile)
                {
                    return RedirectToAction("LogOn", "Account");
                }
            }

            ViewBag.ThumbIcon = uad.FullProfilePicURL;

            SetModelForUserAccount(model, uad);

            //
            var su = new StatusUpdate();
            su.GetMostRecentUserStatus(_ua.UserAccountID);

            if (su.StatusUpdateID > 0)
            {
                model.LastStatusUpdate = su.CreateDate;
                model.MostRecentStatusUpdate = su.Message;
            }

            model.ProfileVisitorCount = ProfileLog.GetUniqueProfileVisitorCount(_ua.UserAccountID);

            GetUserPhotos(model);

            GetUserNews(model);

            model.MetaDescription = _ua.UserName + " " + Messages.Profile + " " +
                                    FromDate.DateToYYYY_MM_DD(_ua.LastActivityDate);

            GetUserPlaylist();

            ForumThreads(_ua.UserAccountID, model);

            if (uad.UserAccountID > 0)
            {
                model.Birthday = uad.BirthDate;

                if (uad.ShowOnMapLegal)
                {
                    // because of the foreign cultures, numbers need to stay in the English version unless a javascript encoding could be added
                    string currentLang = Utilities.GetCurrentLanguageCode();

                    Thread.CurrentThread.CurrentUICulture =
                        CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString());
                    Thread.CurrentThread.CurrentCulture =
                        CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString());

                    model.DisplayOnMap = uad.ShowOnMapLegal;

                    var rnd = new Random();
                    int offset = rnd.Next(10, 100);

                    SiteStructs.LatLong latlong = GeoData.GetLatLongForCountryPostal(uad.Country, uad.PostalCode);

                    if (latlong.latitude != 0 && latlong.longitude != 0)
                    {
                        model.Latitude =
                            Convert.ToDecimal(latlong.latitude + Convert.ToDouble("0.00" + offset))
                                .ToString(CultureInfo.InvariantCulture);
                        model.Longitude =
                            Convert.ToDecimal(latlong.longitude + Convert.ToDouble("0.00" + offset))
                                .ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        model.DisplayOnMap = false;
                    }

                    Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(currentLang);
                    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentLang);
                }

                ViewBag.ThumbIcon = uad.FullProfilePicThumbURL;

                LoadCurrentImagesViewBag(uad.UserAccountID);
            }

            ViewBag.UserAccountDetail = uad;
            ViewBag.UserAccount = _ua;

            GetUserContacts(model);

            UserAccountDetail uadLooker = null;

            if (_mu != null)
            {
                uadLooker = new UserAccountDetail();
                uadLooker.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey));
            }

            if (uadLooker != null &&
                (_mu != null && _ua.UserAccountID > 0 && uadLooker.EnableProfileLogging && uad.EnableProfileLogging))
            {
                var pl = new ProfileLog
                {
                    LookedAtUserAccountID = _ua.UserAccountID,
                    LookingUserAccountID = Convert.ToInt32(_mu.ProviderUserKey)
                };

                if (pl.LookingUserAccountID != pl.LookedAtUserAccountID) pl.Create();

                ArrayList al = ProfileLog.GetRecentProfileViews(_ua.UserAccountID);

                if (al != null && al.Count > 0)
                {
                    var uas = new UserAccounts();

                    foreach (UserAccount viewwer in al.Cast<int>().Select(id =>
                        new UserAccount(id))
                        .Where(viewwer => !viewwer.IsLockedOut && viewwer.IsApproved)
                        .TakeWhile(viewwer => uas.Count < Maxcountusers))
                    {
                        uas.Add(viewwer);
                    }
                }
            }

            GetUserAccountVideos();

            // this is either a youtube user or this is a band
            var art = new Artist();
            art.GetArtistByAltname(userName);

            if (art.ArtistID > 0)
            {
                // try this way for dashers
                model.UserName = art.Name;
            }

            var vids = new Videos();
            var sngrs = new SongRecords();

            if (art.ArtistID == 0)
            {
                vids.GetAllVideosByUser(userName);

                var uavs = new UserAccountVideos();
                uavs.GetRecentUserAccountVideos(_ua.UserAccountID, 'U');

                foreach (Video f2 in uavs.Select(uav1 => new Video(uav1.VideoID)).Where(f2 => !vids.Contains(f2)))
                {
                    vids.Add(f2);
                }

                vids.Sort((x, y) => (y.PublishDate.CompareTo(x.PublishDate)));

                model.UserName = _ua != null ? _ua.UserName : userName;
            }
            else
            {
                GetArtistProfile(art, vids);
            }

            vids.Sort((p1, p2) => p2.PublishDate.CompareTo(p1.PublishDate));
            sngrs.AddRange(vids.Select(v1 => new SongRecord(v1)));

            if (_mu != null && _ua.UserAccountID != Convert.ToInt32(_mu.ProviderUserKey))
            {
                var uc1 = new UserConnection();

                uc1.GetUserToUserConnection(_ua.UserAccountID, Convert.ToInt32(_mu.ProviderUserKey));

                if (uc1.UserConnectionID > 0)
                {
                    switch (uc1.StatusType)
                    {
                        case 'C':
                            if (uc1.IsConfirmed)
                            {
                                model.IsCyberFriend = true;
                            }
                            else
                            {
                                model.IsWatingToBeCyberFriend = true;
                            }
                            break;
                        case 'R':
                            if (uc1.IsConfirmed)
                            {
                                model.IsRealFriend = true;
                            }
                            else
                            {
                                model.IsWatingToBeRealFriend = true;
                            }
                            break;
                        default:
                            model.IsDeniedCyberFriend = true;
                            model.IsDeniedRealFriend = true;
                            break;
                    }
                }
            }

            if (sngrs.Count == 0 && art.ArtistID == 0 && _ua.UserAccountID == 0)
            {
                // no longer exists
                Response.RedirectPermanent("/");
                return new EmptyResult();
            }

            var sngDisplay = new SongRecords();
            sngDisplay.AddRange(from sr1 in sngrs
                let vidToShow = new Video(sr1.VideoID)
                where vidToShow.IsEnabled
                select sr1);

            model.SongRecords = sngDisplay.VideosList();

            return View(model);
        }
Esempio n. 2
0
        public ActionResult VideoSubmit(string video, string videoType, string personType,
            string footageType, string band, string song, string contestID)
        {
            if (string.IsNullOrWhiteSpace(video))
            {
                Response.Redirect("~/videosubmission.aspx?statustype=I");
                return new EmptyResult();
            }
            VideoRequest vir = new VideoRequest();

            vir.RequestURL = video;

            string vidKey = string.Empty;

            vir.RequestURL = vir.RequestURL.Replace("https", "http");

            if (vir.RequestURL.Contains("http://youtu.be/"))
            {
                vir.VideoKey = vir.RequestURL.Replace("http://youtu.be/", string.Empty);
            }
            else if (vir.RequestURL.Contains("http://www.youtube.com/watch?"))
            {
                NameValueCollection nvcKey = System.Web.HttpUtility.ParseQueryString(vir.RequestURL.Replace("http://www.youtube.com/watch?", string.Empty));

                vir.VideoKey = nvcKey["v"];
                vidKey = nvcKey["v"];
            }
            else
            {
                // invalid
                vir.StatusType = 'I';
                Response.Redirect("~/videosubmission.aspx?statustype=I");
                return new EmptyResult();
            }

            if (string.IsNullOrWhiteSpace(videoType) ||
                string.IsNullOrWhiteSpace(personType) ||
                string.IsNullOrWhiteSpace(footageType) ||
                string.IsNullOrWhiteSpace(band) ||
                string.IsNullOrWhiteSpace(song))
            {
                // invalid
                vir.StatusType = 'P';
                Response.Redirect("~/videosubmission.aspx?statustype=P");
                return new EmptyResult();
            }

            try
            {

                //IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();

                //while (enumerator.MoveNext())
                //{

                //    HttpContext.Current.Cache.Remove(enumerator.Key.ToString());

                //}

                //Artists allartsis = new Artists();
                //allartsis.RemoveCache();

                //if (gvwRequestedVideos.SelectedDataKey != null)
                //{
                //    vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value));
                //    vidreq.StatusType = 'A';
                //    vidreq.Update();
                //}

                BootBaronLib.AppSpec.DasKlub.BOL.Video vid = new BootBaronLib.AppSpec.DasKlub.BOL.Video("YT", vidKey);

                vid.ProviderCode = "YT";

                Google.YouTube.Video video2;
                video2 = new Google.YouTube.Video();

                try
                {
                    YouTubeRequestSettings yousettings = new YouTubeRequestSettings("You Manager", devkey, username, password);
                    YouTubeRequest yourequest;
                    Uri Url;

                    yourequest = new YouTubeRequest(yousettings);
                    Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vidKey);

                    video2 = yourequest.Retrieve<Google.YouTube.Video>(Url);
                    vid.Duration = (float)Convert.ToDouble(video2.YouTubeEntry.Duration.Seconds);
                    vid.ProviderUserKey = video2.Uploader;
                    vid.PublishDate = video2.YouTubeEntry.Published;
                }
                catch (GDataRequestException)
                {
                    vid.IsEnabled = false;
                    vid.Update();
                    //litVideo.Text = string.Empty;
                    // return;

                    // invalid
                    vir.StatusType = 'I';
                    Response.Redirect("~/videosubmission.aspx?statustype=I");
                    return new EmptyResult();
                }

                vid.VolumeLevel = 5;
                // vid.HumanType = personType;

                //    t(string video, string videoType, string personType,
                //string footageType, string band, string song, string contestID)

                //  vid.VideoType = videoType;

                //vid.Duration = (float)Convert.ToDouble(txtDuration.Text);
                //vid.Intro = (float)Convert.ToDouble(txtSecondsIn.Text);
                //vid.LengthFromStart = (float)Convert.ToDouble(txtElasedEnd.Text);
                //vid.ProviderCode = ddlVideoProvider.SelectedValue;
                //vid.ProviderUserKey = txtUserName.Text;
                //vid.VolumeLevel = Convert.ToInt32(ddlVolumeLevel.SelectedValue);
                //vid.IsEnabled = chkEnabled.Checked;
                //// vid.IsHidden = chkHidden.Checked;
                //vid.EnableTrim = chkEnabled.Checked;

                ///// publish date
                //YouTubeRequestSettings yousettings =
                //    new YouTubeRequestSettings("You Manager", devkey, username, password);
                //YouTubeRequest yourequest;
                //Uri Url;

                //yourequest = new YouTubeRequest(yousettings);
                //Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.ProviderKey);
                //video = new Google.YouTube.Video();
                //video = yourequest.Retrieve<Google.YouTube.Video>(Url);
                //vid.PublishDate = video.YouTubeEntry.Published;

                if (string.IsNullOrWhiteSpace(vid.ProviderKey))
                {
                    // invalid
                    vir.StatusType = 'I';
                    Response.Redirect("~/videosubmission.aspx?statustype=I");
                    return new EmptyResult();
                }

                if (vid.VideoID == 0)
                {
                    vid.IsHidden = false;
                    vid.IsEnabled = true;
                    vid.Create();
                }
                else
                {
                    vid.Update();
                }

                // if there is a contest, add it now since there is an id
                int subContestID = 0;
                if (!string.IsNullOrWhiteSpace(contestID) && int.TryParse(contestID, out subContestID) && subContestID > 0)
                {
                    //TODO: check if it already is in the contest

                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);

                    ContestVideo cv = new ContestVideo();

                    cv.ContestID = subContestID;
                    cv.VideoID = vid.VideoID;
                    cv.Create();
                }
                else
                {
                    // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL
                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
                }

                PropertyType propTyp = null;
                MultiProperty mp = null;

                // vid type

                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                mp.RemoveCache();
                MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(videoType), vid.VideoID);

                // human

                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                mp.RemoveCache();
                MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(personType), vid.VideoID);

                // footage

                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                mp.RemoveCache();
                MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(footageType), vid.VideoID);

                //// guitar
                //if (!string.IsNullOrWhiteSpace(this.ddlGuitarType.SelectedValue)
                //    && this.ddlGuitarType.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GUITR);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlGuitarType.SelectedValue), vid.VideoID);
                //}

                //// Language
                //if (!string.IsNullOrWhiteSpace(this.ddlLanguage.SelectedValue)
                //    && this.ddlLanguage.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.LANGE);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlLanguage.SelectedValue), vid.VideoID);
                //}

                //// genre
                //if (!string.IsNullOrWhiteSpace(this.ddlGenre.SelectedValue)
                //    && this.ddlGenre.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GENRE);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlGenre.SelectedValue), vid.VideoID);
                //}

                //// difficulty
                //if (!string.IsNullOrWhiteSpace(this.ddlDifficultyLevel.SelectedValue)
                //    && this.ddlDifficultyLevel.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.DIFFC);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(this.ddlDifficultyLevel.SelectedValue), vid.VideoID);
                //}

                //VideoSong.DeleteSongsForVideo(vid.VideoID);

                // song 1

                Artist artst = new Artist(band.Trim());

                if (artst.ArtistID == 0)
                {
                    artst.GetArtistByAltname(band.Trim());
                }

                if (artst.ArtistID == 0)
                {
                    artst.Name = band.Trim();
                    artst.AltName = FromString.URLKey(artst.Name);
                    artst.Create();
                }

                Song sng = new Song(artst.ArtistID, song.Trim());

                if (sng.SongID == 0)
                {
                    sng.Name = sng.Name.Trim();
                    sng.SongKey = FromString.URLKey(sng.Name);
                    sng.Create();
                }

                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1);

                //  RefreshLists();

                //                lblStatus.Text = "OK";

                if (vid.VideoID > 0)
                {
                    Response.Redirect(vid.VideoURL);// just send them to it
                }
            }
            catch
            {
                //              lblStatus.Text = ex.Message;

                //{
                Response.Redirect("~/videosubmission.aspx?statustype=I");
                return new EmptyResult();
                //}

            }

            //Video v1 = new Video();

            //if (!string.IsNullOrEmpty(vir.VideoKey))
            //{
            //    v1 = new Video("YT", vir.VideoKey);
            //}

            //if (v1.VideoID > 0 && v1.IsEnabled)
            //{
            //     Response.Redirect(v1.VideoURL);// just send them to it
            //     return new EmptyResult();
            //}

            //vir.GetVideoRequest();

            //if (vir.StatusType == 'W')
            //{
            //    Response.Redirect("~/videosubmission.aspx?statustype=W");
            //    return new EmptyResult();
            //}
            //else if (vir.StatusType == 'R')
            //{
            //     Response.Redirect("~/videosubmission.aspx?statustype=R");
            //     return new EmptyResult();
            //}

            //vir.StatusType = 'W';
            //vir.Create();
            // Response.Redirect("~/videosubmission.aspx?statustype=W");
            // return new EmptyResult();

            //if (vir.StatusType == 'W')
            //{
            //    Response.Redirect("~/videosubmission.aspx?statustype=W");
            //    return new EmptyResult();
            //}
            //else if (vir.StatusType == 'R')
            //{
            //    Response.Redirect("~/videosubmission.aspx?statustype=R");
            //    return new EmptyResult();
            //}
            //else
            //{
            //    v1 = new Video("YT", vir.VideoKey);

            //    if (v1.VideoID > 0 && v1.IsEnabled)
            //    {
            //        Response.Redirect(v1.VideoURL);// just send them to it
            //    }
            //    else
            //    {
            //        vir.StatusType = 'W';
            //        vir.Create();
            //        Response.Redirect("~/videosubmission.aspx?statustype=W");
            //        return new EmptyResult();
            //    }
            //}

            return new EmptyResult();
        }
Esempio n. 3
0
        public ActionResult VideoSubmit(string video,
            string videoType,
            string personType,
            string footageType,
            string band,
            string song,
            string contestID)
        {
            string invalidSubmissionLink = string.Concat("~/videosubmission.aspx?statustype=", InvalidStatus.ToString());

            if (string.IsNullOrWhiteSpace(video))
            {
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }
            var vir = new VideoRequest {RequestURL = video};

            string vidKey = Utilities.ExtractYouTubeVideoKey(video);
            vir.RequestURL = vir.RequestURL;
            vir.VideoKey = vidKey;

            if (string.IsNullOrWhiteSpace(vir.VideoKey))
            {
                vir.StatusType = InvalidStatus;
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }

            if (string.IsNullOrWhiteSpace(videoType) ||
                string.IsNullOrWhiteSpace(personType) ||
                string.IsNullOrWhiteSpace(footageType) ||
                string.IsNullOrWhiteSpace(band) ||
                string.IsNullOrWhiteSpace(song))
            {
                vir.StatusType = 'P';
                Response.Redirect("~/videosubmission.aspx?statustype=P");
                return new EmptyResult();
            }

            var vid = new Lib.BOL.Video(Provider, vidKey) {ProviderCode = Provider};

            try
            {
                var youTubeVideo = GetYouTubeVideo(vidKey);
                TimeSpan ts = XmlConvert.ToTimeSpan(youTubeVideo.ContentDetails.Duration);
                vid.Duration = (float) Convert.ToDouble(ts.TotalSeconds);
                vid.ProviderUserKey = youTubeVideo.Snippet.ChannelId;
                vid.PublishDate = Convert.ToDateTime(youTubeVideo.Snippet.PublishedAtRaw);
            }
            catch (GDataRequestException gdex)
            {
                vid.IsEnabled = false;
                vid.Update();
                vir.StatusType = InvalidStatus;
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }
            catch (ClientFeedException)
            {
                vir.StatusType = InvalidStatus;
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }
            catch (Exception ex)
            {
                vir.StatusType = InvalidStatus;
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }

            vid.VolumeLevel = 5;

            if (string.IsNullOrWhiteSpace(vid.ProviderKey))
            {
                // invalid
                vir.StatusType = InvalidStatus;
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }

            if (vid.VideoID == 0)
            {
                vid.IsHidden = false;
                vid.IsEnabled = true;
                vid.Create();
            }
            else
            {
                // just go to the video...
                vid.Update();
                Response.Redirect(vid.VideoURL);
            }

            // if there is a contest, add it now since there is an id
            int subContestId;

            if (!string.IsNullOrWhiteSpace(contestID) &&
                int.TryParse(contestID, out subContestId) &&
                subContestId > 0)
            {
                //TODO: check if it already is in the contest

                ContestVideo.DeleteVideoFromAllContests(vid.VideoID);

                var cv = new ContestVideo {ContestID = subContestId, VideoID = vid.VideoID};

                cv.Create();
            }
            else
            {
                // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL
                ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
            }

            // vid type
            var propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
            var mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
            MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
            mp.RemoveCache();
            MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(videoType), vid.VideoID);

            // human
            propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
            mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
            MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
            mp.RemoveCache();
            MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(personType), vid.VideoID);

            // footage
            propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
            mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
            MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
            mp.RemoveCache();
            MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(footageType), vid.VideoID);

            // song 1
            var artst = new Artist(band.Trim());

            if (artst.ArtistID == 0)
            {
                artst.GetArtistByAltname(band.Trim());
            }

            if (artst.ArtistID == 0)
            {
                artst.Name = band.Trim();
                artst.AltName = FromString.UrlKey(artst.Name);
                artst.Create();
            }

            var sng = new Song(artst.ArtistID, song.Trim());

            if (sng.SongID == 0)
            {
                sng.Name = sng.Name.Trim();
                sng.SongKey = FromString.UrlKey(sng.Name);
                sng.Create();
            }

            // BUG: DON'T ADD 2X
            VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1);

            if (vid.VideoID > 0)
            {
                Response.Redirect(vid.VideoURL); // just send them to it
            }

            return new EmptyResult();
        }
Esempio n. 4
0
        public ActionResult ProfileDetail(string userName)
        {
            ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 100 : 277;
            ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 225 : 400;

            ua = new UserAccount(userName);

            UserAccountDetail uad = new UserAccountDetail();
            uad.GetUserAccountDeailForUser(ua.UserAccountID);

            uad.BandsSeen = ContentLinker.InsertBandLinks(uad.BandsSeen, false);
            uad.BandsToSee = ContentLinker.InsertBandLinks(uad.BandsToSee, false);

            MembershipUser mu = Membership.GetUser();

            ProfileModel model = new ProfileModel();

            if (ua.UserAccountID > 0)
            {
                model.UserAccountID = ua.UserAccountID;
                model.PhotoCount = PhotoItems.GetPhotoItemCountForUser(ua.UserAccountID);
                model.CreateDate = ua.CreateDate;
            }

            if (mu != null)
            {
                ViewBag.IsBlocked = BlockedUser.IsBlockedUser(ua.UserAccountID, Convert.ToInt32(mu.ProviderUserKey));
                ViewBag.IsBlocking = BlockedUser.IsBlockedUser(Convert.ToInt32(mu.ProviderUserKey), ua.UserAccountID);

                if (ua.UserAccountID == Convert.ToInt32(mu.ProviderUserKey))
                {
                    model.IsViewingSelf = true;
                }
                else
                {
                    UserConnection ucon = new UserConnection();

                    ucon.GetUserToUserConnection(Convert.ToInt32(mu.ProviderUserKey), ua.UserAccountID);

                    model.UserConnectionID = ucon.UserConnectionID;

                    if (BlockedUser.IsBlockedUser(Convert.ToInt32(mu.ProviderUserKey), ua.UserAccountID))
                    {
                        return RedirectToAction("index", "home");
                    }

                }
            }
            else
            {

                if (uad.MembersOnlyProfile)
                {
                    return RedirectToAction("Account", "LogOn");
                }

            }

            //
            model.UserName = ua.UserName;
            model.CreateDate = ua.CreateDate;
            model.LastActivityDate = ua.LastActivityDate;
            //
            model.DisplayAge = uad.DisplayAge;
            model.Age = uad.YearsOld;
            model.BandsSeen = uad.BandsSeen;
            model.BandsToSee = uad.BandsToSee;
            model.HardwareAndSoftwareSkills = uad.HardwareSoftware;
            model.MessageToTheWorld = uad.AboutDescription;

            model.YouAreFull = uad.Sex;
            model.InterestedInFull = uad.InterestedFull;
            model.RelationshipStatusFull = uad.RelationshipStatusFull ;
            model.RelationshipStatus = uad.RelationshipStatus;
            model.InterestedIn = uad.InterestedIn;
            model.YouAre = uad.YouAre;

            model.Website = uad.ExternalURL;
            model.CountryCode = uad.Country;
            model.CountryName = uad.CountryName;
            model.IsBirthday = uad.IsBirthdayToday;
            model.ProfilePhotoMain = uad.FullProfilePicURL;
            model.ProfilePhotoMainThumb = uad.FullProfilePicThumbURL;
            model.DefaultLanguage = uad.DefaultLanguage;

            model.EnableProfileLogging = uad.EnableProfileLogging;
            model.Handed = uad.HandedFull;
            model.RoleIcon = uad.SiteBages;

            //
            StatusUpdate su = new StatusUpdate();
            su.GetMostRecentUserStatus(ua.UserAccountID);

            if (su.StatusUpdateID > 0)
            {
                model.LastStatusUpdate = su.CreateDate;
                model.MostRecentStatusUpdate = su.Message;
            }

            model.ProfileVisitorCount = ProfileLog.GetUniqueProfileVisitorCount(ua.UserAccountID);

            PhotoItems ptiems = new PhotoItems();
            ptiems.GetUserPhotos(ua.UserAccountID);

            if (ptiems.Count > 0)
            {
                ptiems.Sort((PhotoItem x, PhotoItem y) => (y.CreateDate.CompareTo(x.CreateDate)));

                PhotoItems ptiemsDisplay = new PhotoItems();

                int maxPhotos = 8;

                foreach (PhotoItem pitm1 in ptiems)
                {
                    pitm1.UseThumb = true;
                    if (ptiemsDisplay.Count < maxPhotos)
                    {
                        ptiemsDisplay.Add(pitm1);
                    }
                    else break;
                }

                ptiemsDisplay.UseThumb = true;
                ptiemsDisplay.ShowTitle = false;

                model.HasMoreThanMaxPhotos = (ptiems.Count > maxPhotos);
                ptiemsDisplay.IsUserPhoto = true;
                model.PhotoItems = ptiemsDisplay.ToUnorderdList;
            }

            Contents conts = new Contents();

            conts.GetContentForUser(ua.UserAccountID);

            model.NewsCount = conts.Count;

            if (conts.Count > 0)
            {
                conts.Sort((Content x, Content y) => (y.ReleaseDate.CompareTo(x.ReleaseDate)));

                Contents displayContents = new Contents();
                int maxCont = 1;
                int currentCount = 0;
                foreach (Content ccn1 in conts)
                {
                    currentCount++;
                    if (maxCont >= currentCount)
                    {
                        displayContents.Add(ccn1);
                    }
                    else break;
                }

                displayContents.IncludeStartAndEndTags = false;

                model.NewsArticles = displayContents.ToUnorderdList;

            }

            model.MetaDescription = ua.UserName + " " + BootBaronLib.Resources.Messages.Profile + " " + FromDate.DateToYYYY_MM_DD(ua.LastActivityDate);

            // playlist
            BootBaronLib.AppSpec.DasKlub.BOL.Playlist plyst = new Playlist();

            plyst.GetUserPlaylist(ua.UserAccountID);

            if (plyst.PlaylistID > 0 && PlaylistVideos.GetCountOfVideosInPlaylist(plyst.PlaylistID) > 0)
            {
                ViewBag.AutoPlay = plyst.AutoPlay;
                ViewBag.AutoPlayNumber = (plyst.AutoPlay) ? 1 : 0;
                ViewBag.UserPlaylistID = plyst.PlaylistID;
            }

            if (uad.UserAccountID > 0)
            {
                model.Birthday = uad.BirthDate;

                if (uad.ShowOnMapLegal)
                {

                    byte[] myarray2 = Encoding.Unicode.GetBytes(string.Empty);

                    // because of the foreign cultures, numbers need to stay in the English version unless a javascript encoding could be added
                    string currentLang = Utilities.GetCurrentLanguageCode();

                    Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString());
                    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString());

                    Encoding iso = Encoding.GetEncoding("ISO-8859-1");
                    Encoding utf8 = Encoding.UTF8;

                    model.DisplayOnMap = uad.ShowOnMapLegal;

                    Random rnd = new Random();
                    int offset = rnd.Next(10, 100);

                    SiteStructs.LatLong latlong = GeoData.GetLatLongForCountryPostal(uad.Country, uad.PostalCode);

                    if (latlong.latitude != 0 && latlong.longitude != 0)
                    {
                        model.Latitude = Convert.ToDecimal(latlong.latitude + Convert.ToDouble("0.00" + offset)).ToString();
                        model.Longitude = Convert.ToDecimal(latlong.longitude + Convert.ToDouble("0.00" + offset)).ToString();
                    }
                    else
                    {
                        model.DisplayOnMap = false;
                    }

                    Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(currentLang);
                    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentLang);
                }

                ViewBag.ThumbIcon = uad.FullProfilePicThumbURL;

                LoadCurrentImagesViewBag(uad.UserAccountID);
            }

            ViewBag.UserAccountDetail = uad;
            ViewBag.UserAccount = ua;

            UserConnections ucons = new UserConnections();
            ucons.GetUserConnections(ua.UserAccountID);
            ucons.Shuffle();

            UserAccounts irlContacts = new UserAccounts();
            UserAccounts CyberAssociates = new UserAccounts();
            UserAccount userCon = null;

            foreach (UserConnection uc1 in ucons)
            {
                if (!uc1.IsConfirmed) continue;

                switch (uc1.StatusType)
                {
                    case 'C':
                        if (CyberAssociates.Count >= maxcountusers) continue;

                        if (uc1.ToUserAccountID != ua.UserAccountID)
                        {
                            userCon = new UserAccount(uc1.ToUserAccountID);
                        }
                        else
                        {
                            userCon = new UserAccount(uc1.FromUserAccountID);
                        }
                        CyberAssociates.Add(userCon);
                        break;
                    case 'R':
                        if (irlContacts.Count >= maxcountusers) continue;

                        if (uc1.ToUserAccountID != ua.UserAccountID)
                        {
                            userCon = new UserAccount(uc1.ToUserAccountID);
                        }
                        else
                        {
                            userCon = new UserAccount(uc1.FromUserAccountID);
                        }
                        irlContacts.Add(userCon);
                        break;
                    default:
                        break;
                }
            }

            if (irlContacts.Count > 0)
            {
                model.IRLFriendCount = irlContacts.Count;
            }

            if (CyberAssociates.Count > 0)
            {
                // ViewBag.CyberAssociatesCount = Convert.ToString( CyberAssociates.Count );
                model.CyberFriendCount = CyberAssociates.Count;
            }

            mu = Membership.GetUser();
            UserAccountDetail uadLooker = null;

            if (mu != null)
            {
                uadLooker = new UserAccountDetail();
                uadLooker.GetUserAccountDeailForUser(Convert.ToInt32(mu.ProviderUserKey));
            }

            if (mu != null && ua.UserAccountID > 0 &&
                uadLooker.EnableProfileLogging && uad.EnableProfileLogging)
            {
                ProfileLog pl = new ProfileLog();

                pl.LookedAtUserAccountID = ua.UserAccountID;
                pl.LookingUserAccountID = Convert.ToInt32(mu.ProviderUserKey);

                if (pl.LookingUserAccountID != pl.LookedAtUserAccountID) pl.Create();

                ArrayList al = ProfileLog.GetRecentProfileViews(ua.UserAccountID);

                if (al != null && al.Count > 0)
                {
                    UserAccounts uas = new UserAccounts();

                    UserAccount viewwer = null;

                    foreach (int ID in al)
                    {
                        viewwer = new UserAccount(ID);
                        if (!viewwer.IsLockedOut && viewwer.IsApproved)
                        {
                            if (uas.Count >= maxcountusers) break;

                            uas.Add(viewwer);
                        }
                    }

                   // model.ViewingUsers = uas.ToUnorderdList;
                }
            }

            UserAccountVideos uavs = null;

            if (ua.UserAccountID > 0)
            {
                uavs = new UserAccountVideos();

                uavs.GetRecentUserAccountVideos(ua.UserAccountID, 'F');

                if (uavs.Count > 0)
                {
                    Videos favvids = new Videos();
                    Video f1 = new Video();

                    foreach (UserAccountVideo uav1 in uavs)
                    {
                        f1 = new Video(uav1.VideoID);
                        if (f1.IsEnabled) favvids.Add(f1);
                    }

                    SongRecord sng1 = null;
                    SongRecords sngrcds2 = new SongRecords();

                    foreach (Video v1 in favvids)
                    {
                        sng1 = new SongRecord(v1);
                        sngrcds2.Add(sng1);
                    }

                    sngrcds2.IsUserSelected = true;

                    ViewBag.UserFavorites = sngrcds2.VideosList();//.ListOfVideos();
                }
            }

            // this is either a youtube user or this is a band
            Artist art = new Artist(  );
            art.GetArtistByAltname(userName);

            if (art.ArtistID > 0)
            {
                // try this way for dashers
                model.UserName = art.Name;
            }

            Videos vids = new Videos();
            SongRecords sngrs = new SongRecords();

            if (art.ArtistID == 0)
            {
                vids.GetAllVideosByUser(userName);

                uavs = new UserAccountVideos();
                uavs.GetRecentUserAccountVideos(ua.UserAccountID, 'U');

                Video f2 = null;

                foreach (UserAccountVideo uav1 in uavs)
                {
                    f2 = new Video(uav1.VideoID);

                    if (!vids.Contains(f2)) vids.Add(f2);
                }

                vids.Sort((Video x, Video y) => (y.PublishDate.CompareTo(x.PublishDate)));

                model.UserName = userName;

            }
            else
            {
                // photo
                ArtistProperty aprop = new ArtistProperty();
                aprop.GetArtistPropertyForTypeArtist(art.ArtistID, SiteEnums.ArtistPropertyType.PH.ToString());

                if (!string.IsNullOrEmpty(aprop.PropertyContent))
                {
                    ViewBag.ArtistPhoto = System.Web.VirtualPathUtility.ToAbsolute(aprop.PropertyContent);
                    ViewBag.ThumbIcon = System.Web.VirtualPathUtility.ToAbsolute(aprop.PropertyContent);
                }

                // meta descriptione
                aprop = new ArtistProperty();
                aprop.GetArtistPropertyForTypeArtist(art.ArtistID, SiteEnums.ArtistPropertyType.MD.ToString());
                if (!string.IsNullOrEmpty(aprop.PropertyContent)) ViewBag.MetaDescription = aprop.PropertyContent;

                // description
                aprop = new ArtistProperty();
                aprop.GetArtistPropertyForTypeArtist(art.ArtistID, SiteEnums.ArtistPropertyType.LD.ToString());
                if (!string.IsNullOrEmpty(aprop.PropertyContent)) ViewBag.ArtistDescription = ContentLinker.InsertBandLinks(aprop.PropertyContent, false);

                #region rss
                ///// rss
                //RssResources rssrs = new RssResources();

                //rssrs.GetArtistRssResource(art.ArtistID);

                //if (rssrs.Count > 0)
                //{
                //    RssItems ritems = new RssItems();
                //    RssItems ritemsOUT = new RssItems();

                //    foreach (RssResource rssre in rssrs)
                //    {
                //        ritems.GetTopRssItemsForResource(rssre.RssResourceID);
                //        //ritm = new RssItem(rssre..ArtistID);
                //    }

                //    ritems.Sort((RssItem x, RssItem y) => (y.PubDate.CompareTo(x.PubDate)));

                //    foreach (RssItem ritm in ritems)
                //    {
                //        if (ritemsOUT.Count < 10)
                //        {
                //            ritemsOUT.Add(ritm);
                //        }
                //    }

                //    ViewBag.ArtistNews = ritemsOUT.ToUnorderdList;
                //}
                //else
                //{
                //    ViewBag.ArtistNews = null;
                //}

                //ViewBag.DisplayName = art.DisplayName;
                #endregion

                Songs sngss = new Songs();

                sngss.GetSongsForArtist(art.ArtistID);

                SongRecord snrcd = new SongRecord();

                foreach (Song sn1 in sngss)
                {
                    vids.GetVideosForSong(sn1.SongID);
                }
            }

            vids.Sort(delegate(Video p1, Video p2)
            {
                return p2.PublishDate.CompareTo(p1.PublishDate);
            });

            foreach (BootBaronLib.AppSpec.DasKlub.BOL.Video v1 in vids)
            {
                sngrs.Add(new SongRecord(v1));
            }

            if (mu != null && ua.UserAccountID != Convert.ToInt32(mu.ProviderUserKey))
            {
                UserConnection uc1 = new UserConnection();

                uc1.GetUserToUserConnection(ua.UserAccountID, Convert.ToInt32(mu.ProviderUserKey));

                if (uc1.UserConnectionID > 0)
                {

                    switch (uc1.StatusType)
                    {
                        case 'C':
                            if (uc1.IsConfirmed)
                            {
                                model.IsCyberFriend = true;
                            }
                            else
                            {
                                model.IsWatingToBeCyberFriend = true;
                            }
                            break;
                        case 'R':
                            if (uc1.IsConfirmed)
                            {
                                model.IsRealFriend = true;
                            }
                            else
                            {
                                model.IsWatingToBeRealFriend = true;
                            }
                            break;
                        default:
                            model.IsDeniedCyberFriend = true;
                            model.IsDeniedRealFriend = true;
                            break;
                    }
                }
            }

            if (sngrs == null || sngrs.Count == 0 && art.ArtistID == 0 && ua.UserAccountID == 0)
            {
                // no longer exists
                Response.RedirectPermanent("/");
                return new EmptyResult();
            }

            //sngrs.Sort((SongRecord x, SongRecord y) => (y.cre.CompareTo(x.CreateDate)));

            SongRecords sngDisplay = new SongRecords();

            Video vidToShow = null;

            foreach (SongRecord sr1 in sngrs)
            {
                vidToShow = new Video(sr1.VideoID);

                if (vidToShow.IsEnabled)
                {
                    sngDisplay.Add(sr1);
                }
            }

            model.SongRecords = sngDisplay.VideosList();

            return View(model);
        }