public async Task <ActionResult> Create(OfficeCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (await OfficeManager.IsEntityExistByLamdaAsync(e => e.Name == model.Name))
                {
                    ModelState.AddModelError("", "同名已存在");
                }
                else
                {
                    var dep = await DepartmentManager.FindEntityByIdAsync(model.DepartmentId);

                    if (dep == null)
                    {
                        ModelState.AddModelError("", "指定学院不存在");
                        return(View(model));
                    }
                    var office = new Office()
                    {
                        Name        = model.Name,
                        Description = model.Description,
                        Department  = dep
                    };
                    await OfficeManager.AddEntityAsync(office);

                    office = await OfficeManager.FindOfficeByNameAsync(office.Name);

                    await PositionManager.SetPositionsOfficeAsync(model.IdsToAdd ?? new int[] { }, office);

                    return(RedirectToAction("Index"));
                }
            }
            return(View(model));
        }
        public async Task <ActionResult> Edit(int?id)
        {
            var position = await PositionManager.FindEntityByIdAsync(id ?? 0);

            if (position == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Positions = await PositionManager.GetAllEntities().ToListAsync();

            var departs = await DepartmentManager.GetAllEntities().ToListAsync();

            ViewBag.selectListDepart = new SelectList(departs, "Id", "Name");

            var offices = await OfficeManager.GetOfficesForDepartment(departs.ElementAtOrDefault(0)).ToListAsync();

            ViewBag.selectListOffice = new SelectList(offices, "Id", "Name");

            var teachers = await UserManager.GetNoPositionTeachersAsync();

            ViewBag.selectListTeacher = new SelectList(teachers, "Id", "Name");

            var model = new PositionEditViewModel
            {
                Id          = position.Id,
                Description = position.Description,
                Name        = position.Name,
                UserId      = position.HeadUser.Teacher.Id,
                OfficeId    = position.Office.Id
            };

            return(View(model));
        }
        public async Task <ActionResult> Edit(OfficeEditViewModel model)
        {
            var de = await DepartmentManager.GetAllEntities().ToListAsync();

            ViewBag.SelectListDepart = new SelectList(de, "Id", "Name");

            if (ModelState.IsValid)
            {
                var office = await OfficeManager.FindEntityByIdAsync(model.Id);

                if (office == null)
                {
                    return(View("Error", new[] { "找不到该部门" }));
                }
                var depart = await DepartmentManager.FindEntityByIdAsync(model.DepartmentId);

                if (depart == null)
                {
                    return(View("Error", new[] { "找不到该学院" }));
                }
                office.Name        = model.Name;
                office.Description = model.Description;
                office.Department  = depart;
                await OfficeManager.UpdateEntityAsync(office);

                await PositionManager.ResetPositionsOfficeAsync(model.IdsToRemove ?? new int[] { });

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Esempio n. 4
0
 // Use this for initialization
 void Start()
 {
     doczoomer     = GetComponent <DocumentZoom> ();
     sprend        = GetComponent <SpriteRenderer> ();
     officeman     = GameObject.Find("DeskManager").GetComponent <OfficeManager> ();
     upNoise       = transform.Find("UpNoise").gameObject.GetComponent <AudioSource> ();
     downNoise     = transform.Find("DownNoise").gameObject.GetComponent <AudioSource> ();
     originalColor = sprend.material.color;
     origRendLayer = sprend.sortingOrder;
 }
        public async Task <ActionResult> Edit(PositionEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var departs = await DepartmentManager.GetAllEntities().ToListAsync();

                ViewBag.selectListDepart = new SelectList(departs, "Id", "Name");

                var offices = await OfficeManager.GetOfficesForDepartment(departs.ElementAtOrDefault(0)).ToListAsync();

                ViewBag.selectListOffice = new SelectList(offices, "Id", "Name");

                var teachers = await UserManager.GetNoPositionTeachersAsync();

                ViewBag.selectListTeacher = new SelectList(teachers, "Id", "Name");



                var position = await PositionManager.FindEntityByIdAsync(model.Id);

                if (position != null)
                {
                    var user = await UserManager.FindByIdAsync(model.UserId);

                    if (user == null)
                    {
                        ModelState.AddModelError("", "用户不存在");
                        return(View(model));
                    }
                    var office = await OfficeManager.FindEntityByIdAsync(model.OfficeId);

                    if (office == null)
                    {
                        ModelState.AddModelError("", "部门不存在");
                        return(View(model));
                    }
                    position.Name        = model.Name;
                    position.Description = model.Description;
                    position.HeadUser    = user.TeacherInfo;
                    position.Office      = office;
                    await PositionManager.UpdateEntityAsync(position);

                    user.TeacherInfo.Position = position;
                    await UserManager.UpdateAsync(user);

                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "目标不存在");
                }
            }
            return(View(model));
        }
Esempio n. 6
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         // if so destroy the current instance and instatiate a new one
         Destroy(this.gameObject);
         return;
     }
     // otherwise this instance is of itself
     _instance = this;
 }
Esempio n. 7
0
        internal static void Delete(IDataStore dataStore, IOfficeModel office)
        {
            OfficeManager manager = new OfficeManager(dataStore);

            int num = manager.Delete(office.ApplicationId, office.OfficeId);

            Assert.AreEqual(1, num);
            Assert.IsNull(manager.GetOffice(office.ApplicationId, office.OfficeId));

            Trace.WriteLine("Successfully deleted office " + office.Name);
        }
        public async Task <ActionResult> Create()
        {
            ViewBag.Positions = await PositionManager.FindNoOfficePositions().ToListAsync();

            ViewBag.Offices = await OfficeManager.GetAllEntities().ToListAsync();

            var de = await DepartmentManager.GetAllEntities().ToListAsync();

            ViewBag.SelectListDepart = new SelectList(de, "Id", "Name");
            return(View());
        }
Esempio n. 9
0
    void Awake()
    {
        om      = Object.FindObjectOfType <OfficeManager> ();
        offsetX = transform.position.x;

        msgStartPos = new Vector3[msgBubbles.Length];

        for (int i = 0; i < msgBubbles.Length; i++)
        {
            msgStartPos[i] = msgBubbles [i].transform.position;
        }
    }
Esempio n. 10
0
 // Use this for initialization
 void Start()
 {
     EMPLOYEE_FACTORY    = transform.GetComponent <EmployeeFactory>();
     officeManagerHandle = FindObjectOfType <OfficeManager>();
     numberEmployees     = 0;
     numberOffices       = 0;
     day       = 0;
     dayCicle  = 120;
     timeLeft  = dayCicle;
     dayMoney  = 0;
     nextFloor = 1000;
     InvokeRepeating("Countdown", 1, 1);
 }
        public async Task <ActionResult> Delete(int?id)
        {
            if (ModelState.IsValid)
            {
                var office = await OfficeManager.FindEntityByIdAsync(id ?? 0);

                if (office == null)
                {
                    return(View("Error", new[] { "找不到目标" }));
                }
                await OfficeManager.DeleteEntityAsync(office);
            }
            return(View("Index"));
        }
Esempio n. 12
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            FacilityLists.Add(FacilityInfo.FacilityType.WorkSpace, listOfWorkspaces);
            FacilityLists.Add(FacilityInfo.FacilityType.Catering, listOfCafeterias);
            FacilityLists.Add(FacilityInfo.FacilityType.WaterFountain, listOfBreakRooms);
            FacilityLists.Add(FacilityInfo.FacilityType.Toilets, listOfToilets);
        }

        if (instance != this)
        {
            Destroy(this);
        }
    }
Esempio n. 13
0
 protected new void Awake()
 {
     base.Awake();
     office        = new OfficeManager(gameStats.OfficeInitialSize, officeGenerator, officeStats);
     money         = new MoneyManager(gameStats.InitialMoney);
     employees     = new EmployeeManager(employeeGenerator, employeeStats);
     time          = gameObject.GetComponent <TimeManager>();
     cameraManager = gameObject.GetComponent <CameraManager>();
     cvs           = new CVManager(cvGenerationStats);
     if (FindObjectOfType <AudioManager>())
     {
         FindObjectOfType <AudioManager>().SubscribeEvents();
     }
     OnLoseGame += GameMetaManager.Employee.AllEmployeesByTheWindow;
     // TO DO INSTANCIACION DE PRUEBA
     // employees.CreateNewEmployee(office.DeskList[0]);
 }
        public async Task <ActionResult> Create()
        {
            ViewBag.Positions = await PositionManager.GetAllEntities().ToListAsync();

            var teachers = await UserManager.GetNoPositionTeachersAsync();

            ViewBag.selectListTeacher = new SelectList(teachers, "Id", "Name");

            var departs = await DepartmentManager.GetAllEntities().ToListAsync();

            ViewBag.selectListDepart = new SelectList(departs, "Id", "Name");

            var offices = await OfficeManager.GetOfficesForDepartment(departs.ElementAtOrDefault(0)).ToListAsync();

            ViewBag.selectListOffice = new SelectList(offices, "Id", "Name");

            return(View());
        }
        // GET: Office
        public ActionResult Index(int?p, string searchString, string currentFilter)
        {
            var list = OfficeManager.GetAllEntities();

            if (searchString != null)
            {
                p = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewBag.CurrentFilter = searchString;
            list = list.Where(e => string.IsNullOrEmpty(searchString) || e.Name.Contains(searchString));
            list = list.OrderBy(e => e.Name);
            var pagesize = 5;
            var page     = p ?? 1;

            return(View(list.ToPagedList(page, pagesize)));
        }
Esempio n. 16
0
        internal static IOfficeModel Create(IDataStore dataStore, IApplicationSettings applicationSettings, IApplication application
                                            , DummyDataManager dtm, Random random)
        {
            OfficeManager manager = new OfficeManager(dataStore);

            IOfficeModel office = new OfficeModel(
                application.ApplicationId
                , "OfficeName" + random.Next(1000000, 10000000));

            PopulateWithRandomValues(office, dtm, random);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(application.ApplicationId, office);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);

            IOfficeModel dsOfficeModel = manager.GetOffice(office.ApplicationId, office.OfficeId);

            Assert.IsNotNull(dsOfficeModel);

            return(dsOfficeModel);
        }
        public async Task <ActionResult> Edit(int?id)
        {
            var office = await OfficeManager.FindEntityByIdAsync(id ?? 0);

            if (office == null)
            {
                return(View("Error", new[] { "找不到该部门" }));
            }
            ViewBag.OutPositions = await PositionManager.FindNoOfficePositions().ToListAsync();

            ViewBag.InPositions = office.Positions.ToList();
            var model = new OfficeEditViewModel
            {
                DepartmentId = office.Department.Id,
                Description  = office.Description,
                Id           = office.Id,
                Name         = office.Name
            };
            var de = await DepartmentManager.GetAllEntities().ToListAsync();

            ViewBag.SelectListDepart = new SelectList(de, "Id", "Name");
            return(View(model));
        }
Esempio n. 18
0
        public void Test_CreateUpdateDeleteOffice()
        {
            OfficeManager manager = new OfficeManager(this.DataStore);
            IOfficeModel  record  = Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application
                                           , this.DummyDataManager, this.Random);

            IOfficeModel recordToCompare;

            for (int i = 0; i < this.DefaultUpdateTestIterations; i++)
            {
                PopulateWithRandomValues(record, this.DummyDataManager, this.Random);
                recordToCompare = record;

                manager.Update(record);
                record = manager.GetOffice(record.ApplicationId, record.OfficeId);

                string errors = string.Empty;

                Assert.IsTrue(DebugUtility.ArePropertyValuesEqual(record, recordToCompare, out errors), errors);
                Trace.WriteLine("Update test successfull.");
            }

            Delete(this.DataStore, record);
        }
Esempio n. 19
0
        public IEnumerable <Floor> FloorGetByOfficeID(int id)
        {
            OfficeManager manager = new OfficeManager();

            return(manager.FloorGetByOfficeID(id));
        }
Esempio n. 20
0
        public IEnumerable <Office> GetAll()
        {
            OfficeManager manager = new OfficeManager();

            return(manager.OfficeGetAll());
        }
Esempio n. 21
0
        static void Main(string[] args)
        {
            try
            {
                string        o;
                List <string> p = GetOperationAndParameters(args, out o);
                switch (o.ToLower())
                {
                case "-xlstoxlsx":
                    OfficeManager.ConvertXlsToXlsxFromFileList(p[0], p[1], p[2], p[3]);
                    break;

                case "-delete.xlsx":
                    FileManager.ProcessFileDelegate process_file_deletions = FileManager.ProcessDeleteXlsxFiles;
                    FileManager.GetFiles(p[0], p[1], p[2], process_file_deletions, "deleted_files");
                    Console.WriteLine("done.");
                    break;

                case "-checkxlsconversion":
                    OfficeManager.CheckXlsToXlsxConversion(p[0], p[1], p[2]);
                    break;

                case "-listpwd":
                    OfficeManager.ListXlsPwd(p[0], p[1], p[2], p[3]);
                    break;

                case "-getmissingdirs":
                    FileManager.GetMissingDirectories(p[0], p[1]);
                    break;

                case "-check":
                    FileManager.ProcessFileDelegate process_file_validations = FileManager.ProcessFileValidations;
                    Console.WriteLine("checking validations...");
                    FileManager.GetFiles(p[0], p[1], p[2], process_file_validations, p[3]);
                    FileManager.CheckInvalidFolders(p[0], p[1], p[3]);
                    Console.WriteLine("done.");
                    break;

                case "-getfiles":
                    FileManager.ProcessFileDelegate process_fileInfo = FileManager.ProcessFileInfo;
                    FileManager.GetFiles(p[0], p[1], p[2], process_fileInfo, p[3]);
                    break;

                case "-job.gen":
                    JobManager.GeneratePsJobs(p[0], p[1], p[2], p[3]);
                    break;

                case "-job.run":
                    JobManager j = new JobManager(p[0]);
                    j.ProcessJobs();
                    break;

                case "-users.getsize":
                    FileManager.GetUsersFolderSize(p[0], p[1]);
                    break;

                case "-transits.getsize":
                    FileManager.GetTransitsFolderSize(p[0], p[1]);
                    break;

                default:
                    Console.Write("Invalid operation...");
                    break;
                }

                Console.WriteLine("Press enter to continue...");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
        }
Esempio n. 22
0
 void Awake()
 {
     om = Object.FindObjectOfType <OfficeManager> ();
 }
Esempio n. 23
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();
        }