public PrimaryVideo FirstPrimaryVideo()
        {
            var firstPrimaryVideo = new PrimaryVideo {

                 YouTubeVideo = new Boolean()
            ,
                 YouTubeVideoUrl = null,
                 VimeoVideo = new Boolean()
            ,
                 VimeoVideoUrl = null

             };

            return firstPrimaryVideo;
        }
        public PrimaryVideo ThirdPrimaryVideo()
        {
            var thirdPrimaryVideo = new PrimaryVideo {

                 YouTubeVideo = new Boolean()
            ,
                 YouTubeVideoUrl = null,
                 VimeoVideo = new Boolean()
            ,
                 VimeoVideoUrl = null

             };

            return thirdPrimaryVideo;
        }
        public PrimaryVideo SecondPrimaryVideo()
        {
            var secondPrimaryVideo = new PrimaryVideo {

                 YouTubeVideo = new Boolean()
            ,
                 YouTubeVideoUrl = null,
                 VimeoVideo = new Boolean()
            ,
                 VimeoVideoUrl = null

             };

            return secondPrimaryVideo;
        }
        public void UpdateAgentVideo(PrimaryVideo primaryVideo)
        {
            var agentId = UserHelper.UserIdentity.GetAgentId();
            var agent = UnitofWork.AgentRepository.FindBy
              (x => x.AgentId == agentId).FirstOrDefault();

            if (agent != null)
            {
                agent.VimeoVideo = primaryVideo.VimeoVideo;
                agent.VimeoVideoURL = primaryVideo.VimeoVideoUrl;
                agent.YouTubeVideo = primaryVideo.YouTubeVideo;
                agent.YouTubeVideoURL = primaryVideo.YouTubeVideoUrl;
            }

            UnitofWork.Save();
        }
        public ActionResult UpdateVideo(PrimaryVideo primaryVideo)
        {
            if (ModelState.IsValid)
            {
                var updateVideoSucceeded = true;
                try
                {
                    AccountHelper.UpdateVideoByAccountType(primaryVideo);
                }
                catch (Exception)
                {
                    updateVideoSucceeded = false;
                }

                if (updateVideoSucceeded)
                {
                    return RedirectToAction("UpdateVideo", new { updatevideo = true });

                }
                ModelState.AddModelError("", @"The video url is incorrect.");
                return RedirectToAction("UpdateVideo");
            }
            ModelState.AddModelError("", @"The video url is incorrect.");
            return RedirectToAction("UpdateVideo");
        }
 public ActionResult UpdateVideo(bool? updatevideo)
 {
     var primaryVideoModel = new PrimaryVideo
         {
             VimeoVideo = false,
             VimeoVideoUrl = "",
             YouTubeVideo = false,
             YouTubeVideoUrl = ""
         };
        primaryVideoModel = AccountHelper.LoadVideoByAccountType(primaryVideoModel);
     if (updatevideo != null && updatevideo == true)
     {
         ViewBag.UpdateVideo = true;
         ViewBag.UpdateVideoSuccess = new JNotfiyScriptQueryHelper().JNotifyConfirmationUpdatingVideo();
     }
     return View(primaryVideoModel);
 }
 /// <summary>
 /// Update Video
 /// </summary>
 /// <param name="primaryVideo"></param>
 public void UpdateVideoByAccountType(PrimaryVideo primaryVideo)
 {
     if (HttpContext.User.IsInRole(LookUpRoles.TenantRole))
     {
         UpdateTenantVideo(primaryVideo);
     }
     if (HttpContext.User.IsInRole(LookUpRoles.OwnerRole))
     {
         UpdateOwnerVideo(primaryVideo);
     }
     if (HttpContext.User.IsInRole(LookUpRoles.AgentRole))
     {
         UpdateAgentVideo(primaryVideo);
     }
     if (HttpContext.User.IsInRole(LookUpRoles.SpecialistRole))
     {
         UpdateSpecialistVideo(primaryVideo);
     }
     if (HttpContext.User.IsInRole(LookUpRoles.ProviderRole))
     {
         UpdateProviderVideo(primaryVideo);
     }
 }
        public void UpdateTenantVideo(PrimaryVideo primaryVideo)
        {
            var tenantId = UserHelper.UserIdentity.GetTenantId();
            var tenant = UnitofWork.TenantRepository.FindBy
              (x => x.TenantId == tenantId).FirstOrDefault();

            if (tenant != null)
            {
                tenant.VimeoVideo = primaryVideo.VimeoVideo;
                tenant.VimeoVideoURL = primaryVideo.VimeoVideoUrl;
                tenant.YouTubeVideo = primaryVideo.YouTubeVideo;
                tenant.YouTubeVideoURL = primaryVideo.YouTubeVideoUrl;
            }

            UnitofWork.Save();
        }
        public void UpdateSpecialistVideo(PrimaryVideo primaryVideo)
        {
            var specialistId = UserHelper.UserIdentity.GetSpecialistId();
            var specialist = UnitofWork.SpecialistRepository.FindBy
              (x => x.SpecialistId == specialistId).FirstOrDefault();

            if (specialist != null)
            {
                specialist.VimeoVideo = primaryVideo.VimeoVideo;
                specialist.VimeoVideoURL = primaryVideo.VimeoVideoUrl;
                specialist.YouTubeVideo = primaryVideo.YouTubeVideo;
                specialist.YouTubeVideoURL = primaryVideo.YouTubeVideoUrl;
            }

            UnitofWork.Save();
        }
        public void UpdateProviderVideo(PrimaryVideo primaryVideo)
        {
            var providerId = UserHelper.UserIdentity.GetProviderId();
            var provider = UnitofWork.MaintenanceProviderRepository.FindBy
               (x => x.MaintenanceProviderId == providerId).FirstOrDefault();
            if (provider != null)
            {
                provider.VimeoVideo = primaryVideo.VimeoVideo;
                provider.VimeoVideoURL = primaryVideo.VimeoVideoUrl;
                provider.YouTubeVideo = primaryVideo.YouTubeVideo;
                provider.YouTubeVideoURL = primaryVideo.YouTubeVideoUrl;
            }

            UnitofWork.Save();
        }
 public void UpdateProviderVideo()
 {
     var primaryVideo = new PrimaryVideo
     {
         VimeoVideo = false,
         VimeoVideoUrl = "",
         YouTubeVideo = true,
         YouTubeVideoUrl = "http://www.youtube3.com"
     };
     Controller.UserHelper.UserIdentity.MockJeffProvider();
     Controller.UpdateProviderVideo(primaryVideo);
     Assert.AreEqual(ExpectedProvider.YouTubeVideoURL, @"http://www.youtube3.com");
 }
        public PrimaryVideo LoadTenantVideo( PrimaryVideo primaryVideo)
        {
            var tenantId = UserHelper.UserIdentity.GetTenantId();
            var tenant = UnitofWork.TenantRepository.FindBy
            (x => x.TenantId == tenantId).FirstOrDefault();

            if (tenant != null)
            {
                primaryVideo.VimeoVideo = tenant.VimeoVideo ?? false;
                primaryVideo.VimeoVideoUrl = tenant.VimeoVideoURL ?? "";
                primaryVideo.YouTubeVideo = tenant.YouTubeVideo ?? false;
                primaryVideo.YouTubeVideoUrl = tenant.YouTubeVideoURL ?? "";
            }
            return primaryVideo;
        }
 /// <summary>
 /// Load Video
 /// </summary>
 /// <param name="primaryVideo"></param>
 public PrimaryVideo LoadVideoByAccountType(PrimaryVideo primaryVideo)
 {
     if (HttpContext.User.IsInRole(LookUpRoles.TenantRole))
     {
         LoadTenantVideo(primaryVideo);
     }
     if (HttpContext.User.IsInRole(LookUpRoles.OwnerRole))
     {
         LoadOwnerVideo(primaryVideo);
     }
     if (HttpContext.User.IsInRole(LookUpRoles.AgentRole))
     {
         LoadAgentVideo(primaryVideo);
     }
     if (HttpContext.User.IsInRole(LookUpRoles.SpecialistRole))
     {
         LoadSpecialistVideo(primaryVideo);
     }
     if (HttpContext.User.IsInRole(LookUpRoles.ProviderRole))
     {
         LoadProviderVideo(primaryVideo);
     }
     return null;
 }
        public PrimaryVideo LoadSpecialistVideo(PrimaryVideo primaryVideo)
        {
            var specialistId = UserHelper.UserIdentity.GetSpecialistId();
            var specialist = UnitofWork.SpecialistRepository.FindBy
            (x => x.SpecialistId == specialistId).FirstOrDefault();

            if (specialist != null)
            {
                primaryVideo.VimeoVideo = specialist.VimeoVideo ?? false;
                primaryVideo.VimeoVideoUrl = specialist.VimeoVideoURL ?? "";
                primaryVideo.YouTubeVideo = specialist.YouTubeVideo ?? false;
                primaryVideo.YouTubeVideoUrl = specialist.YouTubeVideoURL ?? "";
            }
            return primaryVideo;
        }
        public PrimaryVideo LoadProviderVideo(PrimaryVideo primaryVideo)
        {
            var providerId = UserHelper.UserIdentity.GetProviderId();
            var provider = UnitofWork.MaintenanceProviderRepository.FindBy
            (x => x.MaintenanceProviderId == providerId).FirstOrDefault();

            if (provider != null)
            {
                primaryVideo.VimeoVideo = provider.VimeoVideo;
                primaryVideo.VimeoVideoUrl = provider.VimeoVideoURL ?? "";
                primaryVideo.YouTubeVideo = provider.YouTubeVideo;
                primaryVideo.YouTubeVideoUrl = provider.YouTubeVideoURL ?? "";
            }
            return primaryVideo;
        }
        public PrimaryVideo LoadOwnerVideo(PrimaryVideo primaryVideo)
        {
            var ownerId = UserHelper.UserIdentity.GetOwnerId();
            var owner = UnitofWork.OwnerRepository.FindBy
            (x => x.OwnerId == ownerId).FirstOrDefault();

            if (owner != null)
            {
                primaryVideo.VimeoVideo = owner.VimeoVideo ?? false;
                primaryVideo.VimeoVideoUrl = owner.VimeoVideoURL ?? "";
                primaryVideo.YouTubeVideo = owner.YouTubeVideo ?? false;
                primaryVideo.YouTubeVideoUrl = owner.YouTubeVideoURL ?? "";
            }
            return primaryVideo;
        }
 public void UpdateTenantVideo()
 {
     var primaryVideo = new PrimaryVideo
     {
         VimeoVideo = false,
         VimeoVideoUrl = "",
         YouTubeVideo = true,
         YouTubeVideoUrl = "http://www.youtube2.com"
     };
     Controller.UserHelper.UserIdentity.MockTenantFred();
     Controller.UpdateTenantVideo(primaryVideo);
     Assert.AreEqual(ExpectedTenant.YouTubeVideoURL, @"http://www.youtube2.com");
 }
 public void UpdateSpecialistVideo()
 {
     var primaryVideo = new PrimaryVideo
     {
         VimeoVideo = false,
         VimeoVideoUrl = "",
         YouTubeVideo = true,
         YouTubeVideoUrl = "http://www.youtube4.com"
     };
     Controller.UserHelper.UserIdentity.MockSaraSpecialist();
     Controller.UpdateSpecialistVideo(primaryVideo);
     Assert.AreEqual(ExpectedSpecialist.YouTubeVideoURL, @"http://www.youtube4.com");
 }
        public void UpdateOwnerVideo(PrimaryVideo primaryVideo)
        {
            var ownerId = UserHelper.UserIdentity.GetOwnerId();
            var owner = UnitofWork.OwnerRepository.FindBy
              (x => x.OwnerId == ownerId).FirstOrDefault();

            if (owner != null)
            {
                owner.VimeoVideo = primaryVideo.VimeoVideo;
                owner.VimeoVideoURL = primaryVideo.VimeoVideoUrl;
                owner.YouTubeVideo = primaryVideo.YouTubeVideo;
                owner.YouTubeVideoURL = primaryVideo.YouTubeVideoUrl;
            }

            UnitofWork.Save();
        }
 public PrimaryVideo DefaultPrimaryVideo()
 {
     var primaryVideo = new PrimaryVideo
     {
         VimeoVideo = false,
         VimeoVideoUrl = "",
         YouTubeVideo = true,
         YouTubeVideoUrl = "http://www.youtube.com"
     };
     return primaryVideo;
 }