Exemplo n.º 1
0
        public void GetReviews()
        {
            List <ReviewModel> reviews = ReviewManager.GetReviews();
            int expected = 2;

            Assert.AreEqual(reviews.Count, expected);
        }
        public void TestFilledReviews()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

            optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new HomeMyDayDbContext(optionsBuilder.Options);

            context.Reviews.Add(new Review()
            {
                Id            = 1,
                Name          = "TestReview",
                Accommodation = new Accommodation()
                {
                    Id = 1, Name = "TestAccommodation"
                },
                Approved = true,
                Date     = DateTime.Now,
                Title    = "Test",
                Text     = "Dit was een goede vakantie!"
            });

            context.SaveChanges();

            IReviewRepository reviewRepository = new EFReviewRepository(context, null);
            IReviewManager    reviewManager    = new ReviewManager(reviewRepository);

            var target = new ReviewController(reviewManager);

            var result = target.Index();
            var model  = result.Model as IEnumerable <ReviewViewModel>;

            Assert.NotNull(model);
            Assert.Equal("TestReview", model.FirstOrDefault().Name);
        }
Exemplo n.º 3
0
        public static void StartPolling()
        {
            if (!Utils.GlobalConfiguration.DisablePolling)
            {
                RecurringJob.AddOrUpdate(() => QuestionManager.QueryQueuedQuestions(), "*/2 * * * *");

                RecurringJob.AddOrUpdate(() => RecentlyClosed(), "*/5 * * * *");
                RecurringJob.AddOrUpdate(() => PollRecentCloseVotes(), "*/5 * * * *");
                RecurringJob.AddOrUpdate(() => PollMostCloseVotes(), "*/5 * * * *");
                RecurringJob.AddOrUpdate(() => ReviewManager.GetRecentCloseVoteReviews(), "*/5 * * * *");

                //Every hour
                RecurringJob.AddOrUpdate(() => SOCVRManager.CheckCVPls(), "0 * * * *");

                //Query this every 15 minutes (except on the hour)
                RecurringJob.AddOrUpdate(() => PollActiveQuestionsFifteenMins(), "15,30,45 * * * *");

                //Query this every hour (except every four hours)
                RecurringJob.AddOrUpdate(() => PollActiveQuestionsHour(), "0 1,2,3,5,6,7,9,10,11,13,14,15,17,18,19,21,22,23 * * *");

                //Every 4 hours (except at midnight)
                RecurringJob.AddOrUpdate(() => PollActiveQuestionsFourHours(), "0 4,8,12,16,20 * * *");

                //Every day
                RecurringJob.AddOrUpdate(() => PollActiveQuestionsDay(), "0 0 * * *");

                //ChatroomManager.JoinAndWatchSOCVR();

                PollFrontPage();
            }
        }
Exemplo n.º 4
0
    /**
     * Requests new Review and if no error shows banner
     */
    internal static IEnumerator RequestReview()
    {
        _reviewManager = new ReviewManager();
        var requestFlowOperation = _reviewManager.RequestReviewFlow();

        yield return(requestFlowOperation);

        if (requestFlowOperation.Error != ReviewErrorCode.NoError)
        {
            // Log error. For example, using requestFlowOperation.Error.ToString().
            yield break;
        }

        _playReviewInfo = requestFlowOperation.GetResult();

        var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);

        yield return(launchFlowOperation);

        _playReviewInfo = null; // Reset the object
        if (launchFlowOperation.Error != ReviewErrorCode.NoError)
        {
            // Log error. For example, using requestFlowOperation.Error.ToString().
            yield break;
        }
    }
Exemplo n.º 5
0
        IEnumerator RequestReviewObject()
        {
            if (enableLog)
            {
                Debug.Log("Requesting Review Object");
            }

#if UNITY_EDITOR
            StartCoroutine(ShowReviewObject());
#endif

            _reviewManager = new ReviewManager();

            var requestFlowOperation = _reviewManager.RequestReviewFlow();
            yield return(requestFlowOperation);

            if (requestFlowOperation.Error != ReviewErrorCode.NoError)
            {
                if (enableLog)
                {
                    Debug.LogError("Requesting Review Object Error" + requestFlowOperation.Error.ToString());
                }

                yield break;
            }

            if (enableLog)
            {
                Debug.Log("Requesting Review Object Success");
            }
            _playReviewInfo = requestFlowOperation.GetResult();

            StartCoroutine(ShowReviewObject());
        }
Exemplo n.º 6
0
    public IEnumerator StartTheReview()
    {
        _reviewManager = new ReviewManager();
        var requestFlowOperation = _reviewManager.RequestReviewFlow();

        yield return(requestFlowOperation);

        if (requestFlowOperation.Error != ReviewErrorCode.NoError)
        {
            // Log error. For example, using requestFlowOperation.Error.ToString().
            yield break;
        }

        var _playReviewInfo     = requestFlowOperation.GetResult();
        var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);

        yield return(launchFlowOperation);

        _playReviewInfo = null; // Reset the object
        if (launchFlowOperation.Error != ReviewErrorCode.NoError)
        {
            // Log error. For example, using requestFlowOperation.Error.ToString().
            yield break;
        }
        // The flow has finished. The API does not indicate whether the user
        // reviewed or not, or even whether the review dialog was shown. Thus, no
        // matter the result, we continue our app flow.
    }
Exemplo n.º 7
0
        private void SetSeoInformation(String product)
        {
            var seo = ReviewManager.GetReviewSeo(product);

            ViewBag.Title       = seo.PageTitle;
            ViewBag.Description = seo.PageDescription;
            ViewBag.HasNoFollow = true;
        }
Exemplo n.º 8
0
        /// <summary>
        /// 专家评分表显示
        /// </summary>
        /// <param name="reviewId"></param>
        /// <returns></returns>
        public async Task <IActionResult> RateTable(int reviewId)
        {
            var review = await ReviewRepository.GetAsync(reviewId);

            var rateTable = await ReviewManager.GetRateTable(review);

            return(View(rateTable));
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            //facade
            DataManager   dataManager   = new DataManager();
            ReviewManager reviewManager = new ReviewManager();
            RatingFacade  ratingPortal  = new RatingFacade(dataManager, reviewManager);

            ratingPortal.Start();


            //proxy
            List <string> resourses = new() { "EBEC", "Chess tournament", "WIPZ KR" };
            UserRequest   request   = new UserRequest();

            System.Console.WriteLine("\nSimulating work for unregistered User");
            foreach (var res in resourses)
            {
                RealResource realResource = new RealResource(res);
                Proxy        proxy        = new Proxy(realResource, 0); //unregistered user, wirh accessLevel = 0
                request.Get(proxy);
            }
            System.Console.WriteLine("\nSimulating work for registered User");
            foreach (var res in resourses)
            {
                RealResource realResource = new RealResource(res);
                Proxy        proxy        = new Proxy(realResource, 1); //unregistered user, wirh accessLevel = 0
                request.Get(proxy);
            }


            //composite
            //student requesting info for PZ
            Client client = new Client();

            //PZ construction
            System.Console.WriteLine("\n\nInfo about PZ\n");
            Composite PZ = new Composite();

            Composite Title = new Composite();

            Title.Add(new Leaf("Title: Prog Zabezp"));
            Composite Rating = new Composite();

            Rating.Add(new Leaf("Rating: 10/12"));
            Composite Content = new Composite();

            Content.Add(new Leaf("Content: Nice stuff"));
            Composite Comments = new Composite();

            Comments.Add(new Leaf("Comments: How about Levus?"));
            PZ.Add(new List <Component> {
                Title, Rating, Content, Comments
            });
            //client.GetContent(PZ);
            client.AddNewComponent(Comments, new Leaf("\tComment: not well..."));
            client.GetContent(PZ);
        }
    }
Exemplo n.º 10
0
 public ReviewPageModel(
     ReviewManager manager,
     BlobCodeFileRepository codeFileRepository,
     CommentsManager commentsManager)
 {
     _manager            = manager;
     _codeFileRepository = codeFileRepository;
     _commentsManager    = commentsManager;
 }
Exemplo n.º 11
0
        public ActionResult DeleteReview(int id)
        {
            _reviewManager = ReviewManagerFactory.Create();
            var response = _reviewManager.DeleteReview(id);

            //error out if success == false

            return(RedirectToAction("Reviews"));
        }
Exemplo n.º 12
0
        public void Delete()
        {
            List <ReviewModel> reviewModels = ReviewManager.GetReviews();

            ReviewModel review = reviewModels.FirstOrDefault(r => r.Subject == "something else");
            bool        result = ReviewManager.Delete(review.ReviewID);

            Assert.IsTrue(result);
        }
Exemplo n.º 13
0
        public ScreenShareOpsComplexManager()
        {
            uow = new UnitOfWork(new Database.Context.AydinUniversityProjectContext());

            connectionManager  = uow.GetManager <ConnectionManager, Connection>();
            userManager        = uow.GetManager <UserManager, User>();
            eduManager         = uow.GetManager <EducationManager, Education>();
            lessonManager      = uow.GetManager <LessonManager, Lesson>();
            screenShareManager = uow.GetManager <ScreenShareManager, ScreenShareRequest>();
            reviewManager      = uow.GetManager <ReviewManager, Review>();
        }
Exemplo n.º 14
0
        public ReviewServiceTest()
        {
            IReviewRepository  reviewRepository  = new StubReviewRepository();
            IProductRepository productRepository = GetProductRepository();
            IUserRepository    userRepository    = GetUserOnRepository();
            IReviewManager     reviewManager     = new ReviewManager(reviewRepository, userRepository, productRepository);
            ICartManager       cartManager       = GetCartManager(productRepository, userRepository);

            reviewService = new ReviewServiceImpl(reviewManager, cartManager, new ReviewDTOBuilder());
            request       = GetReviewRequest(cartManager);
        }
        public void TestAddReview()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

            optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new HomeMyDayDbContext(optionsBuilder.Options);

            var accommodation = new Accommodation()
            {
                Id   = 1,
                Name = "TestAccommodation"
            };

            context.Accommodations.Add(accommodation);
            context.SaveChanges();

            IAccommodationRepository accommodationRepository = new EFAccommodationRepository(context);

            IReviewRepository reviewRepository = new EFReviewRepository(context, accommodationRepository);

            var dummy       = Encoding.ASCII.GetBytes("{}");
            var sessionMock = new Mock <ISession>();

            sessionMock.Setup(x => x.TryGetValue(It.IsAny <string>(), out dummy)).Returns(true).Verifiable();

            var httpContext = new DefaultHttpContext
            {
                Session = sessionMock.Object
            };

            IReviewManager reviewManager = new ReviewManager(reviewRepository);

            var target = new ReviewController(reviewManager)
            {
                TempData = new TempDataDictionary(httpContext, new SessionStateTempDataProvider())
            };

            ReviewViewModel reviewViewModelToAdd = new ReviewViewModel()
            {
                AccommodationId = accommodation.Id,
                Name            = "TestReviewAddTest",
                Approved        = true,
                Date            = DateTime.Now,
                Title           = "TestReviewAdd",
                Text            = "Dit was goed!"
            };

            var result = target.AddReview(reviewViewModelToAdd) as RedirectToActionResult;

            Assert.NotNull(result.ActionName);
            Assert.NotNull(result.ControllerName);
            Assert.Equal("Detail", result.ActionName);
            Assert.Equal("Accommodation", result.ControllerName);
        }
Exemplo n.º 16
0
        public List <Review> GetReviews(string trainingId)
        {
            var reviewManager = new ReviewManager();
            int iTrainingId   = 0;

            if (!Int32.TryParse(trainingId, out iTrainingId))
            {
                return(null);
            }
            return(reviewManager.GetReviewsForTraining(iTrainingId));
        }
Exemplo n.º 17
0
        public ReviewBackgroundHostedService(ReviewManager reviewManager, IConfiguration configuration)
        {
            _reviewManager = reviewManager;
            // We can disable background task using app settings if required
            var taskDisabled = configuration["BackgroundTaskDisabled"];

            if (!String.IsNullOrEmpty(taskDisabled) && taskDisabled == "true")
            {
                _isDisabled = true;
            }
        }
Exemplo n.º 18
0
 public ConversationModel(
     IConfiguration configuration,
     BlobCodeFileRepository codeFileRepository,
     CommentsManager commentsManager,
     ReviewManager reviewManager)
 {
     _codeFileRepository = codeFileRepository;
     _commentsManager    = commentsManager;
     _reviewManager      = reviewManager;
     Endpoint            = configuration.GetValue <string>(ENDPOINT_SETTING);
 }
Exemplo n.º 19
0
    private void OnLevelChanged(int level)
    {
#if (UNITY_ANDROID && !UNITY_EDITOR)
        if (level == _targetLevel)
        {
            _reviewManager = new ReviewManager();

            StartCoroutine(RequestReview());
        }
#endif
    }
        public async void GetReviews()
        {
            RestService   restSevice      = new RestService();
            ReviewManager myReviewManager = new ReviewManager(restSevice);
            List <Review> listReviewss    = await myReviewManager.GetReviewsAsync(profileUser.Id);

            Reviews.Clear();
            foreach (var item in listReviewss)
            {
                Reviews.Add(item);
            }
        }
Exemplo n.º 21
0
 public ReviewPageModel(
     ReviewManager manager,
     BlobCodeFileRepository codeFileRepository,
     CommentsManager commentsManager,
     NotificationManager notificationManager,
     UserPreferenceCache preferenceCache)
 {
     _manager             = manager;
     _codeFileRepository  = codeFileRepository;
     _commentsManager     = commentsManager;
     _notificationManager = notificationManager;
     _preferenceCache     = preferenceCache;
 }
Exemplo n.º 22
0
 public ReviewController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     ILoggerFactory loggerFactory,
     ReviewManager rwManager,
     NotificationManager notificationManager)
 {
     _userManager         = userManager;
     _signInManager       = signInManager;
     _logger              = loggerFactory.CreateLogger <ReviewController>();
     _reviewManager       = rwManager;
     _notificationManager = notificationManager;
 }
        internal static List <IUIData> GetData(UserInfo UserInfo)
        {
            Dictionary <string, IUIData> Settings = new Dictionary <string, IUIData>
            {
                { "States", new UIData {
                      Name = "States", Options = ReviewManager.GetStatesforReview(UserInfo.PortalID, UserInfo.UserID), OptionsText = "Text", OptionsValue = "Value", Value = "0"
                  } },
                { "NotificationExtensionURL", new UIData {
                      Name = "NotificationExtensionURL", Value = ServiceProvider.NavigationManager.NavigateURL("", "mid=0", "icp=true", "guid=cd8c127f-da66-4036-b107-90061361cf87")
                  } }
            };

            return(Settings.Values.ToList());
        }
Exemplo n.º 24
0
        public IHttpActionResult FindMostRatedSuppliers()
        {
            try
            {
                ReviewManager RevMgr = new ReviewManager(Unit);

                return(Ok(RevMgr.FindMostRatedSuppliersIds()));
            }
            catch (Exception ex)
            {
                Unit.LogError(ex, this.ToString(), this.ActionContext.ActionArguments.ToList());
                return(InternalServerError(ex));
            }
        }
Exemplo n.º 25
0
        public ActionResult AddReview(ReviewVM newReview)
        {
            _tagsManager     = TagsManagerFactory.Create();
            _reviewManager   = ReviewManagerFactory.Create();
            _categoryManager = CategoryManagerFactory.Create();

            if (ModelState.IsValid)
            {
                try
                {
                    if (User.IsInRole("Admin"))
                    {
                        newReview.Review.IsApproved = true;
                        newReview.Review.UserId     = User.Identity.GetUserId();
                    }

                    //set dates
                    newReview.Review.DateCreated = DateTime.Now;

                    //send review to manager
                    _reviewManager.AddReview(newReview.Review);

                    if (newReview.NewTags != null)
                    {
                        //create array of tags from tags input
                        string[] tags = newReview.NewTags.Split(',');

                        //send tags to tag manager
                        TResponse <List <Tags> > tagList = _tagsManager.AddListOfTags(tags);

                        //add tags to review
                        _reviewManager.AddTagsToReview(newReview.Review.ReviewId, tagList.Payload);
                    }

                    return(RedirectToAction("Reviews"));
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Something wrong happened while adding a review:", ex);
                }
            }
            else
            {
                //reset view
                TResponse <List <Categories> > response = _categoryManager.GetCategoryList();
                newReview.SetCategoryListItems(response.Payload);
                return(View(newReview));
            }
        }
Exemplo n.º 26
0
        private async Task <ReviewManager> CreateReviewService(IEnumerable <Review> testData)
        {
            await context.Reviews.AddRangeAsync(testData);

            await context.SaveChangesAsync();

            var reviewRepository = new ReviewRepository(context);
            var userRepository   = new UserRepository(context);
            var pieceRepository  = new PieceRepository(context);
            var albumRepository  = new AlbumRepository(context);
            var artistRepository = new ArtistRepository(context);
            var service          = new ReviewManager(reviewRepository, pieceRepository, albumRepository, artistRepository, userRepository);

            return(service);
        }
Exemplo n.º 27
0
        public async Task <IActionResult> RateTableView(int reviewRoundId, int projectId, long expertId)
        {
            var reviewDetail = await ReviewRoundRepository.GetAsync(reviewRoundId);

            var review = reviewDetail.Review;

            var rateTable = await ReviewManager.GetRateTable(review);

            var projectReviewDetail = reviewDetail.ExpertReviewDetails.Single(o => o.ExpertID == expertId).ProjectReviewDetails.Single(o => o.ProjectId == projectId);

            //打分详情
            ViewData["projectReviewDetail"] = projectReviewDetail;

            return(View(rateTable));
        }
Exemplo n.º 28
0
 public ProfileController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     ILoggerFactory loggerFactory,
     ReviewManager rwManager,
     MessageManager messageManager,
     NotificationManager notificationManager)
 {
     _userManager         = userManager;
     _signInManager       = signInManager;
     _logger              = loggerFactory.CreateLogger <AccountController>();
     _reviewManager       = rwManager;
     _messageManager      = messageManager;
     _notificationManager = notificationManager;
 }
Exemplo n.º 29
0
        public void Update()
        {
            List <ReviewModel> reviewModels = ReviewManager.GetReviews();

            ReviewModel review = reviewModels.FirstOrDefault(r => r.Subject == "Test");

            review.Subject = "something else";


            ReviewManager.Update(review);

            ReviewModel newReview = ReviewManager.GetReview(review.ReviewID);


            Assert.AreEqual(review.Subject, newReview.Subject);
        }
Exemplo n.º 30
0
        public ActionResult EditReview(ReviewVM model)
        {
            _tagsManager     = TagsManagerFactory.Create();
            _reviewManager   = ReviewManagerFactory.Create();
            _categoryManager = CategoryManagerFactory.Create();

            if (ModelState.IsValid)
            {
                try
                {
                    //set dates
                    model.Review.DateCreated = DateTime.Now;

                    //send review to manager
                    _reviewManager.EditReview(model.Review);

                    if (model.NewTags != null)
                    {
                        //create array of tags from tags input
                        string[] tags = model.NewTags.Split(',');

                        //send tags to tag manager
                        TResponse <List <Tags> > tagList = _tagsManager.AddListOfTags(tags);

                        //add tags to review
                        _reviewManager.AddTagsToReview(model.Review.ReviewId, tagList.Payload);
                    }

                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    //catch an exception and add

                    throw new ApplicationException("Something wrong happened while adding a review:", ex);
                }
            }
            else
            {
                //reset view
                var tagsResponse = _tagsManager.GetTagByReviewId(model.Review.ReviewId);
                model.TagList = tagsResponse.Payload;
                TResponse <List <Categories> > response = _categoryManager.GetCategoryList();
                model.SetCategoryListItems(response.Payload);
                return(View(model));
            }
        }
        public bool Save(ReviewModel model)
        {
            var reviewManager = new ReviewManager();

            var review = new Review();
            review.Restaurant = new RestaurantManager().Get(model.RestaurantId);
            review.ReviewTime = DateTime.Now;
            review.Comment = model.Comment;
            review.Author = GetUserInfo();
            review.Food = model.Food;
            review.Ambience = model.Ambience;
            review.Service = model.Service;

            reviewManager.Add(review);

            return true;
        }
        public List<ReviewModel> GetAll(int Id)
        {
            var reviewManager = new ReviewManager();
            var lstReview = reviewManager.GetByRestaurant(Id)
                .Select(r => new ReviewModel()
                {
                    Ambience = r.Ambience,
                    Author = r.Author.Name,
                    PhotoUrl = r.Author.PhotoUrl,
                    Food = r.Food,
                    Comment = r.Comment,
                    Service = r.Service,
                    Stars = r.Stars,
                })
                .ToList();

            return lstReview;
        }
Exemplo n.º 33
0
        public static void MigrateSurveyCustomer()
        {
            PortalDbContext portalDbContext = new PortalDbContext();
            PortalDbRepository<Access> accesPortalDbRepository = new PortalDbRepository<Access>(portalDbContext);
            PortalDbRepository<SurveyCustomer> surveyCustomerRepository = new PortalDbRepository<SurveyCustomer>(portalDbContext);
            PortalDbRepository<SurveyQuestion> surveyQuestionRepository = new PortalDbRepository<SurveyQuestion>(portalDbContext);
            PortalDbRepository<SurveysGeneralAnswer> surveysGeneralAnswerRepository = new PortalDbRepository<SurveysGeneralAnswer>(portalDbContext);
            PortalDbRepository<SurveysPossibleAnswer> surveyPossibleAnswerRepository = new PortalDbRepository<SurveysPossibleAnswer>(portalDbContext);

            Manager portalDbManager = new Manager(accesPortalDbRepository);
            /////////////===================>>>>>>>>>>>>>>>>>>>
            SurveyCustomerDbManager SurveyCustomerDbManager = new SurveyCustomerDbManager(surveyCustomerRepository, portalDbManager);
            SurveyQuestionManager SurveyQuestionManager = new SurveyQuestionManager(surveyQuestionRepository, portalDbManager);
            SurveyGeneralAnswerManager SurveyGeneralAnswerManager = new SurveyGeneralAnswerManager(surveysGeneralAnswerRepository, portalDbManager);
            SurveyPossibleAnswerManager SurveyPossibleAnswerManager = new SurveyPossibleAnswerManager(surveyPossibleAnswerRepository, portalDbManager);

            //////////////////////////////////////////////////
            CosmeticExpressDbContext cosmeticExpressDbContext = new CosmeticExpressDbContext();
            CosmeticExpressDbRepository<Access> accesCosmeticExpressDbRepository = new CosmeticExpressDbRepository<Access>(cosmeticExpressDbContext);
            CosmeticExpressDbRepository<User> userRepository = new CosmeticExpressDbRepository<User>(cosmeticExpressDbContext);
            CosmeticExpressDbRepository<Schedule> scheduleRepository = new CosmeticExpressDbRepository<Schedule>(cosmeticExpressDbContext);
            CosmeticExpressDbRepository<Office> officeRepository = new CosmeticExpressDbRepository<Office>(cosmeticExpressDbContext);
            CosmeticExpressDbRepository<VWCompleteSurgery> VWCompleteSurgeryRepository = new CosmeticExpressDbRepository<VWCompleteSurgery>(cosmeticExpressDbContext);
            CosmeticExpressDbRepository<Entity.CosmeticExpress.Patient> CosmeticExpressPatientRepository = new CosmeticExpressDbRepository<Entity.CosmeticExpress.Patient>(cosmeticExpressDbContext);


            Manager cosmeticExpressDbManager = new Manager(accesCosmeticExpressDbRepository);
            UserManager userManager = new UserManager(userRepository, cosmeticExpressDbManager);
            ScheduleManager scheduleManager = new ScheduleManager(scheduleRepository, cosmeticExpressDbManager);
            OfficeManager officeManager = new OfficeManager(officeRepository, cosmeticExpressDbManager);
            VWCompleteSurgeryManager vwCompleteSurgeryManager = new VWCompleteSurgeryManager(VWCompleteSurgeryRepository, cosmeticExpressDbManager);
            CosmeticExpressPatientManager CosmeticExpressPatientManager = new CosmeticExpressPatientManager(CosmeticExpressPatientRepository, cosmeticExpressDbManager);

            //////////////////////////////////////////////////
            ApplicationDbContext applicationDbContext = new ApplicationDbContext();
            ApplicationDbRepository<Access> accesApplicationDbRepository = new ApplicationDbRepository<Access>(applicationDbContext);
            ApplicationDbRepository<Review> reviewRepository = new ApplicationDbRepository<Review>(applicationDbContext);
            ApplicationDbRepository<Doctor> doctorRepository = new ApplicationDbRepository<Doctor>(applicationDbContext);
            ApplicationDbRepository<Lead> leadRepository = new ApplicationDbRepository<Lead>(applicationDbContext);
            ApplicationDbRepository<Expert> expertRepository = new ApplicationDbRepository<Expert>(applicationDbContext);
            ApplicationDbRepository<Center> centerRepository = new ApplicationDbRepository<Center>(applicationDbContext);
            ApplicationDbRepository<Entity.ReviewManagerEntities.Patient> ApplicationPatientRepository = new ApplicationDbRepository<Entity.ReviewManagerEntities.Patient>(applicationDbContext);


            Manager applicationDbManager = new Manager(accesApplicationDbRepository);
            ReviewManager reviewManager = new ReviewManager(reviewRepository, applicationDbManager);
            ///////////////////=============================>>>>>>>>>>>>>>>
            DoctorManager doctorManager = new DoctorManager(doctorRepository, applicationDbManager);
            LeadManager leadManager = new LeadManager(leadRepository, applicationDbManager);
            ExpertManager expertManager = new ExpertManager(expertRepository, applicationDbManager);
            CenterManager centerManager = new CenterManager(centerRepository, applicationDbManager);
            ApplicationPatientManager ApplicationPatientManager = new ApplicationPatientManager(ApplicationPatientRepository, cosmeticExpressDbManager);

            var SurveyQuestionCollection = SurveyQuestionManager.Get().ToArray();
            var SurveyCustomerCollection = SurveyCustomerDbManager.Get().ToArray();
            var SurveyPossibleAnswerCollection = SurveyPossibleAnswerManager.Get().ToArray();
            var SurveyGeneralAnswerCollection = SurveyGeneralAnswerManager.Get().ToArray();
            ICollection<VWCompleteSurgery> vwCompleteSurgeriesCollection = vwCompleteSurgeryManager.Get().ToArray();

            var doctors = doctorManager.Get().Select(d => new{ d.Id, d.FullName, d.Reviews.Count }).ToArray();
            var sources = reviewManager.Get().GroupBy(r => r.Source).ToArray().Select(group => new {Source = group.Key, Count = group.Count()});

            ICollection<Review> ReviewCollection = new List<Review>();

            foreach (var sgAnswer in SurveyGeneralAnswerCollection)
            {
                if (!reviewManager.Get().Any(review => review.ExternalId == sgAnswer.Id && review.Source == "Portal") && sgAnswer.SurveyTemplateId == 2)
                {
                    //Schedule Schedule = scheduleManager.Get(sched =>
                    //sched.PatientID == sgAnswer.SurveyCustomer.ExternalId
                    //&& sched.ServiceID == 5
                    //&& sched.dtStart.AddMonths(3) >= sgAnswer.SurveyDate).FirstOrDefault();

                    VWCompleteSurgery surgery = vwCompleteSurgeriesCollection.Where(surg => surg.PatientID == sgAnswer.SurveyCustomer.ExternalId && surg.dtStart.AddMonths(3) >= sgAnswer.SurveyDate).FirstOrDefault();


                    if (surgery != null)
                    {
                        Review review = new Review();
                        review.Source = "Portal";
                        review.ExternalId = sgAnswer.Id;
                        review.Rating = 0;

                        review.CreatedOn = surgery.dtStart;

                        //FROM CEXPRESS/Patient/Patient
                        Entity.CosmeticExpress.Patient CosmeticExpressPatient = CosmeticExpressPatientManager.Get(patient => patient.PatientID == surgery.PatientID).FirstOrDefault();
                        var existingApplicationPatient = ApplicationPatientManager.Get(patient => patient.ExternalId == CosmeticExpressPatient.PatientID && patient.Source == "CosmeticExpress").FirstOrDefault();
                        if (existingApplicationPatient != null)
                        {
                            review.PatientId = existingApplicationPatient.Id;
                        }
                        else
                        {
                            Entity.ReviewManagerEntities.Patient Patient = new Entity.ReviewManagerEntities.Patient()
                            {
                                ExternalId = CosmeticExpressPatient.PatientID,
                                FirstName = CosmeticExpressPatient.FirstName,
                                LastName = CosmeticExpressPatient.LastName,
                                MiddleName = CosmeticExpressPatient.MiddleName,
                                DOB = CosmeticExpressPatient.DOB,
                                Email = CosmeticExpressPatient.Email,
                                Source = "CosmeticExpress"
                            };
                            review.Patient = Patient;
                        }


                        //FROM CEXPRESS/USER TO APP/DOCTOR 
                        User User = userManager.Get(user => user.UserID == surgery.ProviderUserID).FirstOrDefault();
                        var existingDoctorinDb = doctorManager.Get(doc => doc.ExternalId == User.UserID && doc.Source == "CosmeticExpress").FirstOrDefault();
                        var reviewInCollectionWithSameDoctor = ReviewCollection.FirstOrDefault(rev => rev.Doctor != null && rev.Doctor.ExternalId == User.UserID && rev.Doctor.Source == "CosmeticExpress");
                        if (existingDoctorinDb != null)
                        {
                            review.DoctorId = existingDoctorinDb.Id;
                        }
                        else
                        {
                            if (reviewInCollectionWithSameDoctor != null)
                            {
                                review.Doctor = reviewInCollectionWithSameDoctor.Doctor;
                            }
                        }
                        if (review.Doctor == null && review.DoctorId == null)
                        {
                            {
                                Doctor Doctor = new Doctor()
                                {
                                    FullName = User.FullName,
                                    Source = "CosmeticExpress",
                                    ExternalId = User.UserID
                                };
                                review.Doctor = Doctor;
                            }
                        }

                        //FROM CEXPRESS/OFFICE TO APP/CENTER 
                        Office Office = officeManager.Get(office => office.OfficeId == surgery.OfficeID).FirstOrDefault();

                        var existingCenterinDb = centerManager.Get(center => center.ExternalId == surgery.OfficeID).FirstOrDefault();
                        var centerInCollectionWithSameDoctor = ReviewCollection.FirstOrDefault(rev => rev.Center != null && rev.Center.ExternalId == Office.OfficeId && rev.Center.Source == "CosmeticExpress");

                        if (existingCenterinDb != null)
                        {
                            review.CenterId = existingCenterinDb.Id;
                        }
                        else
                        {
                            if (centerInCollectionWithSameDoctor != null)
                            {
                                review.Center = centerInCollectionWithSameDoctor.Center;
                            }
                        }
                        if (review.Center == null && review.CenterId == null)
                        {
                            Center Center = new Center()
                            {
                                Name = Office.OfficeName,
                                Source = "CosmeticExpress",
                                ExternalId = Office.OfficeId
                            };
                            review.Center = Center;                           
                        }

                        //Recorriendo cada pregunta dentro del survey para calcular el rating
                        foreach (var answer in sgAnswer.SurveysAnswers)
                        {
                            if (SurveyQuestionCollection.FirstOrDefault(q => q.Id == answer.SurveyQuestionId).QuestionType == "edit")
                            {
                                review.Text = answer.Answer != null ? answer.Answer.ToString() : "Empty";
                            }
                            else
                            {
                                var anwersItem = SurveyPossibleAnswerCollection.FirstOrDefault(spa => spa.Id == answer.SurveysPossibleAnswerId);
                                review.Rating += anwersItem != null ? anwersItem.Weight : 0;
                            }
                        }
                        //anadiento el review a la coleccion
                        ReviewCollection.Add(review);
                    }
                }
            }
            //from ReviewCollection to reviewManager
            foreach (var review in ReviewCollection)
            {
                reviewManager.Add(review);               
            }
            reviewManager.SaveChanges();
        }