private IQueryable <Company> GetCompaniesForRanking(User UserLogged, TestsServices testService, int sector, int questionnaire, int?country, bool associated) { if (country.HasValue) { if (associated) { return(testService.GetByQuestionnaire(questionnaire).Where(t => t.Evaluations.Count > 0 && t.Evaluations.Select(l => l.Location.State.Country_Id == country.Value).Count() > 0).Select(t => t.Company).Where(c => c.ShowClimate == true && c.CompanySector_Id == sector && c.CompanyAssociated_Id == UserLogged.Company_Id).Distinct()); } else { return(testService.GetByQuestionnaire(questionnaire).Where(t => t.Evaluations.Count > 0 && t.Evaluations.Select(l => l.Location).Where(lo => lo.State.Country_Id == country.Value).Count() > 0).Select(t => t.Company).Where(c => c.ShowClimate == true && c.CompanySector_Id == sector).Distinct()); } } else { if (associated) { IQueryable <Test> auxt = testService.GetByQuestionnaire(questionnaire).Where(t => t.Evaluations.Count > 0); IQueryable <Company> auxc = auxt.Select(c => c.Company); auxc = auxc.Where(c => c.ShowClimate == true && c.CompanySector_Id == sector && c.CompanyAssociated_Id == UserLogged.Company_Id).Distinct(); //return testService.GetByQuestionnaire(questionnaire).Where(t => t.Evaluations.Count > 0).Select(t => t.Company).Where(c => c.ShowClimate == true && c.CompanySector_Id == sector && c.CompanyAssociated_Id == UserLogged.Company_Id).Distinct(); return(auxc); } else { return(testService.GetByQuestionnaire(questionnaire).Where(t => t.Evaluations.Count > 0).Select(t => t.Company).Where(c => c.ShowClimate == true && c.CompanySector_Id == sector).Distinct()); } } }
public Dictionary <Company, double> GetRankingForCompany(User UserLogged, Test test, int?sector_id, int?questionnaire_id, int?country_id, bool associated) //GetRankingForCompany saca el cuestionario y el sector de la compa;ia { TestsServices testService = new TestsServices(); int sector; int questionnaire; GetQuestionnaireAndSectorByUserLogged(UserLogged, test, sector_id, questionnaire_id, testService, out sector, out questionnaire); Dictionary <Company, double> resultsByCompany = new Dictionary <Company, double>(); IQueryable <Company> Companies = GetCompaniesForRanking(UserLogged, testService, sector, questionnaire, country_id, associated); Test companyTest; double climate; foreach (Company company in Companies)//busca la ultima medicion de cada compañia { companyTest = testService.GetLastTestByCompany(company.Id, questionnaire, country_id); if (country_id.HasValue) { climate = companyTest.GetGeneralAvgOrMedByUbication(true, null, null, null, country_id, null, null).Values.FirstOrDefault(); } else { climate = companyTest.GetGeneralAvgOrMed(true, null, null, null).Values.FirstOrDefault(); } climate = (double)(climate * 100) / companyTest.Questionnaire.Options.Count;//le busca el clima a cada una y lo pasa a % climate = Convert.ToDouble(String.Format("{0:0.##}", climate)); resultsByCompany.Add(company, climate); } return(resultsByCompany); }
private Color GetColorPoint(double value) { decimal pct = (decimal)(value * 100 / options); Test test = new TestsServices().GetById(test_id); if (test.ClimateScale_Id.HasValue) { ClimateRange range = test.ClimateScale.ClimateRanges.Where(r => r.MinValue <= pct && r.MaxValue >= pct).OrderBy(r => r.MaxValue).FirstOrDefault(); return(System.Drawing.ColorTranslator.FromHtml(range.Color)); } else { if (pct > 80) { return(Color.Green); } else if (pct > 60 && pct <= 80) { return(Color.Yellow); } else { return(Color.Red); } } }
public TestViewModel() { //InitializeComponent (); var testservices = new TestsServices(); TestsList = testservices.GetTestInfo(); }
// generate a list of Id of all the demographic selected by the user without the Functional organization private List <int> MobileGeneratesID(Evaluation evaluation) { List <int> lista = new List <int>(); Test test = new TestsServices().GetById(evaluation.Test_Id); List <string> demographics = test.DemographicsInTests.Select(d => d.Demographic.Name).ToList(); if (demographics.Contains("AgeRange")) { lista.Add(evaluation.Age_Id.Value); } if (demographics.Contains("InstructionLevel")) { lista.Add(evaluation.InstructionLevel_Id.Value); } if (demographics.Contains("PositionLevel")) { lista.Add(evaluation.PositionLevel_Id.Value); } if (demographics.Contains("Seniority")) { lista.Add(evaluation.Seniority_Id.Value); } if (demographics.Contains("Location")) { lista.Add(evaluation.Location_Id.Value); } if (demographics.Contains("Performance")) { lista.Add(evaluation.Performance_Id.Value); } return(lista); }
public ActionResult MobileWithDemographicAnswerTest(string Code, int Id) { FormCollection collection = new FormCollection(); collection["EvaluationId"] = Id.ToString(); collection["evaluation.Test_Id"] = new TestsServices().GetByCode(Code).Id.ToString(); Evaluation evaluation = GetEvaluationFromExisting(collection); Test test = new TestsServices().GetById(evaluation.Test_Id); int idQuestionnaireToUse; Questionnaire questionnaireToUse; if (test.OneQuestionnaire) { idQuestionnaireToUse = test.Questionnaire_Id.Value; questionnaireToUse = test.Questionnaire; _evaluationViewModel = new EvaluationViewModel(test, evaluation, Selected_FO, idQuestionnaireToUse, questionnaireToUse); } else { int idSelectorValue = MobileGetSelectorValue(evaluation); InitializeViewForQuestionsViews(test, idSelectorValue); _evaluationViewModel.SetEvaluation(evaluation); _evaluationViewModel.SetSelectedFo(Selected_FO); } return(View("Questionnaire.Mobile", _evaluationViewModel)); }
public ActionResult MobileAnswerTest(FormCollection collection) { Evaluation evaluation = MobileGenerateEvaluationObject(collection); Test test = new TestsServices().GetById(evaluation.Test_Id); if (User.Identity.Name.ToLower() == "cigeh" && test.Questionnaire_Id == 32 && existEmailInTicket(collection["q[10033739]"].ToString())) { ViewData["emailError"] = "El Email ya ha sido utilizado"; return(RedirectToAction("ErrorEvaluation")); } if (ModelState.IsValid) { if (ValidateAnswerCount(collection, evaluation)) { if (_evaluationService.Add(evaluation)) { new TestsServices().IncreaseCurrentEvaluationsAndDecreaseEvaluationsLeft(evaluation.Test_Id); InsertAnswers(collection, evaluation); InsertFunctionalOrganizations(evaluation); if (User.Identity.Name.ToLower() == "cigeh" && test.Questionnaire_Id == 32) { GenerateTicket(collection, evaluation.Id); SendMail(collection["q[10033738]"].ToString(), collection["q[10033739]"].ToString(), evaluation.Id); } return(RedirectToAction("EvaluationSucceeded", new { @evaluation_id = evaluation.Id })); } } else { return(RedirectToAction("ErrorEvaluation")); } } return(View("Questionnaire.Mobile", _evaluationViewModel)); }
// Se invoca este metodo cuando se responde los datos demograficos public ActionResult MobileDemographicsAnswerTest(FormCollection collection) { if (ModelState.IsValid) { Evaluation evaluation = collection["evaluation.Id"].ToString() == "0" ? GenerateEvaluationObject(collection) : GetEvaluationFromExisting(collection); Test test = new TestsServices().GetById(evaluation.Test_Id); int idQuestionnaireToUse; Questionnaire questionnaireToUse; if (test.OneQuestionnaire) { idQuestionnaireToUse = test.Questionnaire_Id.Value; questionnaireToUse = test.Questionnaire; _evaluationViewModel = new EvaluationViewModel(test, evaluation, Selected_FO, idQuestionnaireToUse, questionnaireToUse); } else { int idSelectorValue = MobileGetSelectorValue(evaluation); InitializeViewForQuestionsViews(test, idSelectorValue); _evaluationViewModel.SetEvaluation(evaluation); _evaluationViewModel.SetSelectedFo(Selected_FO); } return(View("Questionnaire.Mobile", _evaluationViewModel)); } return(RedirectToAction("ErrorClosedEvaluation")); }
private void MobileInitializeViewsForDemographics(string code, int?previousEvaluationId) { //Evaluation previousEvaluation = previousEvaluationId.HasValue ? _evaluationService.GetById(previousEvaluationId.Value) : null; Evaluation previousEvaluation = new Evaluation(); Evaluation evaluation = new Evaluation(); Test test = new TestsServices().GetByCode(code); evaluation.Test_Id = test.Id; SelectList agesList = new SelectList(new AgesServices().GetAgesForDropDownList(test.Company_Id), "Key", "Value"); SelectList senioritiesList = new SelectList(new SenioritiesServices().GetSenioritiesForDropDownList(test.Company_Id), "Key", "Value"); SelectList instructionLevelsList = new SelectList(new InstructionLevelsServices().GetInstructionLevelsForDropDownList(test.Company_Id), "Key", "Value"); SelectList positionLevelsList = new SelectList(new PositionLevelsServices().GetPositionLevelsForDropDownList(test.Company_Id), "Key", "Value"); SelectList locationsList = new SelectList(new LocationsServices().GetLocationsForDropDownList(test.Company_Id), "Key", "Value"); IQueryable <DemographicsInTest> dem = new DemographicsInTestsServices().GetByTest(test.Id).Where(d => d.FOT_Id.HasValue); List <int> dems = new List <int>(); foreach (DemographicsInTest d in dem) { dems.Add(d.FOT_Id.Value); } IQueryable <FunctionalOrganizationType> FOTypes = new FunctionalOrganizationTypesServices().GetByCompany(test.Company_Id).Where(d => dems.Contains(d.Id)); SelectList FOrganizations = new SelectList(new FunctionalOrganizationsServices().GetEmptyDictionary()); SelectList performanceEvaluationsList = new SelectList(new PerformanceEvaluationsServices().GetPerformanceEvaluationsForDropDownList(test.Company_Id), "Key", "Value"); _evaluationViewModel = new EvaluationViewModel(evaluation, agesList, senioritiesList, instructionLevelsList, positionLevelsList, locationsList, FOTypes, FOrganizations, performanceEvaluationsList, test, previousEvaluation); }
private static int GetQuestionnaireIdFromEvaluation(Evaluation evaluation) { Test test = new TestsServices().GetById(evaluation.Test_Id); DemographicsInTest demographicInTest = new DemographicsInTestsServices().GetSelector(test.Id); int selectorFromEvaluation = GetSelectorId(evaluation, test, demographicInTest); int questionnaire_id = new DemographicSelectorDetailsServices().GetQuestionnaireIdByDemographicSelectorDetailValues(test.Id, demographicInTest.Demographic_Id, selectorFromEvaluation); return(questionnaire_id); }
private Evaluation MobileGenerateEvaluationObject(FormCollection collection) { Evaluation evaluation = new Evaluation(); evaluation.Test_Id = int.Parse(collection["evaluation.Test_Id"]); evaluation.IpAddress = Request.ServerVariables["REMOTE_ADDR"]; evaluation.RemoteHostName = GetMACAddress(); //collection["MacAddress"];//GetMACAddress(); //Request.ServerVariables["REMOTE_HOST"]; evaluation.RemoteUserName = GetMacAddress2(); //Request.ServerVariables["REMOTE_USER"]; Test test = new TestsServices().GetById(evaluation.Test_Id); List <string> demographics = test.DemographicsInTests.Select(d => d.Demographic.Name).ToList(); if (demographics.Contains("AgeRange")) { evaluation.Age_Id = int.Parse(collection["evaluation.Age_Id"]); } if (demographics.Contains("InstructionLevel")) { evaluation.InstructionLevel_Id = int.Parse(collection["evaluation.InstructionLevel_Id"]); } if (demographics.Contains("PositionLevel")) { evaluation.PositionLevel_Id = int.Parse(collection["evaluation.PositionLevel_Id"]); } if (demographics.Contains("Seniority")) { evaluation.Seniority_Id = int.Parse(collection["evaluation.Seniority_Id"]); } if (demographics.Contains("Location")) { evaluation.Location_Id = int.Parse(collection["evaluation.Location_Id"]); } if (demographics.Contains("Performance")) { evaluation.Performance_Id = int.Parse(collection["evaluation.Performance_Id"]); } if (demographics.Contains("Gender")) { evaluation.Sex = GetGender(collection["evaluation.Sex"].ToString()); } Dictionary <int, string> FO = new FunctionalOrganizationTypesServices().GetFunctionalOrganizationTypesForDropDownList(test.Company_Id); for (int i = 0; i < 2; i++) { Selected_FO[i] = new int[FO.Count]; } int j = 0; foreach (var v in FO) { Selected_FO[0][j] = v.Key; // Functional Organization Id Selected_FO[1][j] = int.Parse(collection["FO" + j + ""]); // Select Functional Organization j++; } evaluation.CreationDate = DateTime.Now; ValidateEvaluationModel(evaluation); return(evaluation); }
public FileResult UniVariateChartByPerformance(string chartSize, string chartType, int graphic_id, int test_id, int?category_id, int?question_id) { Test test = new TestsServices().GetById(test_id); ChartDetails cd = new ChartDetails(chartSize, chartType, false, this.GetChartDetails(graphic_id, test_id), 2, test.GetAvgAndMedByPerformanceEvaluations(category_id, question_id), test_id); MemoryStream ms = new MemoryStream(); cd.chart.SaveImage(ms); return(new FileContentResult(ms.GetBuffer(), @"image/png")); }
public FileResult UniVariateChartByState(string chartSize, string chartType, int country_id, int test_id, int?category_id, int?question_id) { Test test = new TestsServices().GetById(test_id); ChartDetails cd = new ChartDetails(chartSize, chartType, false, this.GetChartDetails(12, 13), 2, test.GetAvgAndMedByStates(null, null, country_id), test_id); MemoryStream ms = new MemoryStream(); cd.chart.SaveImage(ms); return(new FileContentResult(ms.GetBuffer(), @"image/png")); }
public void ApplyTwoInOneAndOneEuroless_WhenThereAreTwoOrMuchVouchersAndThreeOrMoreTshirts() { this.shoppingBasketDtoMock.Setup(s => s.Products).Returns(TestsServices.CreateListWithThreeVouchersAndThreeTshirts()); ShoppingBasketService sut = new ShoppingBasketService(shoppingBasketDtoMock.Object, mapperServiceMock.Object, efDbSetWrapper.Object, efDbContextSaveChanges.Object); //act var result = sut.GetTotalPrice() - sut.ApplyDiscountVoucher() - sut.ApplyDiscountTshirt(); //assert Assert.AreEqual(74.5, result); }
public void ReturnsTotalPriceOfTheProducts() { //arrange shoppingBasketDtoMock.Setup(s => s.Products).Returns(TestsServices.CreateListWithThreeVouchersAndThreeTshirts()); ShoppingBasketService sut = new ShoppingBasketService(shoppingBasketDtoMock.Object, mapperServiceMock.Object, efDbSetWrapper.Object, efDbContextSaveChanges.Object); //act var result = sut.GetTotalPrice(); //assert Assert.AreEqual(82.5, result); }
public void NotApplyOneEuroLess_WhenThereAreLessOfThreeTshirts() { //arrange shoppingBasketDtoMock.Setup(s => s.Products).Returns(TestsServices.CreateListWithTwoTshirts()); ShoppingBasketService sut = new ShoppingBasketService(shoppingBasketDtoMock.Object, mapperServiceMock.Object, efDbSetWrapper.Object, efDbContextSaveChanges.Object); //act var result = sut.GetTotalPrice() - sut.ApplyDiscountVoucher() - sut.ApplyDiscountTshirt(); //assert Assert.AreEqual(57.5, result); }
public ActionResult LoadDivQuestions(int test_id, int idSelectorValue) { Test test = new TestsServices().GetById(test_id); InitializeViewForQuestionsViews(test, idSelectorValue); if (test.GroupByCategories) { return(PartialView("GroupByCategoriesPartial", _evaluationViewModel)); } else { return(PartialView("GroupBySortOrderPartial", _evaluationViewModel)); } }
public ActionResult TestInstructions(string code) { Test test = new TestsServices().GetByCode(code); ValidateEvaluationModel(test); if (ModelState.IsValid) { InitializeViewsForTestInstructions(test); return(View(_evaluationViewModel)); } else { return(RedirectToAction("Index", "Home")); } }
public int GetCategoriesCountByTest(int test_id) { int numberOfCategories = 0; Test test = new TestsServices().GetById(test_id); if (test.OneQuestionnaire) { numberOfCategories = test.Questionnaire.Categories.Count(); } else { numberOfCategories = test.Company.Categories.Where(p => !p.CategoryGroup_Id.HasValue).Count(); } return(numberOfCategories); }
public ChartDetails(string chartSize, string chartType, bool tresD, string title, int series, string demographic, IEnumerable Values, int?test_id, bool print)//devuelve el gráfico { this.demographic = demographic; int tot; if (demographic == "General" && chartType == "Pie") { tot = new TestsServices().GetById(test_id.Value).EvaluationNumber; } else { tot = new TestsServices().GetById(test_id.Value).Evaluations.Count; } SetProperties(chartSize, chartType, tresD, title, series, Values, test_id, tot, print); }
public JsonResult GetCategoriesByCompanyTest(int test_id) { List <object> categories = new List <object>(); int company_id = new TestsServices().GetById(test_id).Company_Id; foreach (var category in _categoryService.GetGroupingCategoriesByCompanyForDropDownList(company_id)) { categories.Add( new { optionValue = category.Key, optionDisplay = category.Value, }); } return(Json(categories)); }
private IQueryable <Country> GetCountries(User UserLogged) { IQueryable <Test> tests; if (UserLogged.Role.Name == "HRAdministrator") { tests = new TestsServices().GetTestsByAssociated(UserLogged.Company_Id); } else { tests = new TestsServices().GetByCompany(UserLogged.Company_Id); } IQueryable <Country> countries = tests.SelectMany(e => e.Evaluations.Select(l => l.Location.State.Country)).Distinct().AsQueryable(); return(countries); }
public JsonResult GetBarInfo(int test_id, string demographic) { Test test = new TestsServices().GetById(test_id); Dictionary <string, object> data_aux = test.GetAvgAndMedByAgeRanges(null, null, null, false); Dictionary <string, double> data = (Dictionary <string, double>)data_aux["Average"]; Dictionary <string, object> options = new Dictionary <string, object>() { { "title", "Sample received" }, { "is3D", true }, { "width", 400 }, { "height", 300 }, { "colors", new string[] { "#FF69B4", "#00BFFF" } } }; object[] info = new object[] { data, options }; return(Json(info)); }
public bool ValidateAnswerCount(FormCollection collection, Evaluation evaluation) { bool contains; int questionnaireId; if (new TestsServices().GetById(evaluation.Test_Id).OneQuestionnaire) { questionnaireId = new TestsServices().GetById(evaluation.Test_Id).Questionnaire_Id.Value; } else { questionnaireId = GetQuestionnaireIdFromEvaluation(evaluation); } int count = collection.AllKeys.ToList().FindAll(findQ).Count; contains = new QuestionsServices().GetQuestionsCountByQuestionnaire(questionnaireId) == count; return(contains); }
//Se invoca esta accion cuando se va a responder una encuesta en la cual //se ha llenado un test previo y por ende, no hace falta completar el test public ActionResult MobileWithoutDemographicAnswerTest(string Code) { FormCollection collection = new FormCollection(); collection["evaluation.Test_Id"] = new TestsServices().GetByCode(Code).Id.ToString(); Evaluation evaluation = GenerateEvaluationObject(collection); Test test = new TestsServices().GetById(evaluation.Test_Id); int idQuestionnaireToUse; Questionnaire questionnaireToUse; if (test.OneQuestionnaire) { idQuestionnaireToUse = test.Questionnaire_Id.Value; questionnaireToUse = test.Questionnaire; _evaluationViewModel = new EvaluationViewModel(test, evaluation, Selected_FO, idQuestionnaireToUse, questionnaireToUse); } return(View("Questionnaire.Mobile", _evaluationViewModel)); }
//public JsonResult GetInfoForMap(int? country_id, int company_id) //{ // int company; // TestsServices testService = new TestsServices(); // if (company_id != 0) // company = company_id; // else // company = new UsersServices().GetByUserName(User.Identity.Name).Company_Id; // Dictionary<int, Test> lastTests = new Dictionary<int, Test>(); // if (!country_id.HasValue) // { // List<Country> countriesByCompany = new LocationsServices().GetCountriesByCompany(company); // foreach (Country country in countriesByCompany) // { // Test aux = testService.GetLastTestByCompanyAndCountry(company, country.Id); // if (aux != null) // lastTests.Add(country.Id, aux); // } // } // else // { // List<State> statesByCompany = new LocationsServices().GetStatesByCompany(company, country_id.Value); // foreach (State state in statesByCompany) // { // Test aux = testService.GetLastTestByCompanyAndState(company, state.Id); // if (aux != null) // lastTests.Add(state.Id, aux); // } // } // List<object> finalList = new List<object>(); // Dictionary<string[], double> listClimate = new Dictionary<string[], double>(); // if (country_id.HasValue) // { // foreach (Test t in lastTests.Values.Distinct()) // { // List<int> statesInt = lastTests.Where(v => v.Value == t).Select(k => k.Key).ToList(); // listClimate = t.GetGeneralPctgByState(country_id.Value, statesInt); // //listClimate = new Results(t).GetPositiveAnswersPercentageByState(country_id.Value, statesInt); // AddToFinalList(finalList, t, listClimate); // } // } // else // { // foreach (Test t in lastTests.Values.Distinct()) // { // List<int> countriesInt = lastTests.Where(v => v.Value == t).Select(k => k.Key).ToList(); // //listClimate = new Results(t).GetPositiveAnswersPercentageByCountry(countriesInt); // listClimate = t.GetGeneralPctgByCountry(countriesInt); // AddToFinalList(finalList, t, listClimate); // } // } // return Json(finalList); //} public JsonResult GetInfoForMap(int test_id, int?country_id) { Test test = new TestsServices().GetById(test_id); List <object> finalList = new List <object>(); Dictionary <string[], double> listClimate = new Dictionary <string[], double>(); if (country_id.HasValue) { List <int> statesInt = new EvaluationsServices().GetStatesByTest(test_id, country_id.Value); listClimate = test.GetGeneralPctgByState(country_id.Value, statesInt); AddToFinalList(finalList, test, listClimate); } else { List <int> countriesInt = new EvaluationsServices().GetCountriesByTest(test_id); listClimate = test.GetGeneralPctgByCountry(countriesInt); AddToFinalList(finalList, test, listClimate); } return(Json(finalList)); }
private void InitializeViewsForDemographics(string code, int?previousEvaluationId) { Evaluation evaluation; Test test; SelectList agesList; SelectList senioritiesList; SelectList instructionLevelsList; SelectList positionLevelsList; SelectList locationsList; SelectList performanceEvaluationsList; IQueryable <FunctionalOrganizationType> FOTypes; SelectList FOrganizations; Evaluation previousEvaluation = previousEvaluationId.HasValue ? _evaluationService.GetById(previousEvaluationId.Value) : null; evaluation = new Evaluation(); //if (previousEvaluationId.HasValue) //{ // evaluation.Age_Id = previousEvaluation.Age_Id; // evaluation.InstructionLevel_Id = previousEvaluation.InstructionLevel_Id; // evaluation.Location_Id = previousEvaluation.Location_Id; // evaluation.Performance_Id = previousEvaluation.Performance_Id; // evaluation.PositionLevel_Id = previousEvaluation.PositionLevel_Id; // evaluation.Seniority_Id = previousEvaluation.Seniority_Id; // evaluation.Sex = previousEvaluation.Sex; // evaluation.EvaluationFOs = previousEvaluation.EvaluationFOs; //} test = new TestsServices().GetByCode(code); evaluation.Test_Id = test.Id; agesList = new SelectList(new AgesServices().GetAgesForDropDownList(test.Company_Id), "Key", "Value"); senioritiesList = new SelectList(new SenioritiesServices().GetSenioritiesForDropDownList(test.Company_Id), "Key", "Value"); instructionLevelsList = new SelectList(new InstructionLevelsServices().GetInstructionLevelsForDropDownList(test.Company_Id), "Key", "Value"); positionLevelsList = new SelectList(new PositionLevelsServices().GetPositionLevelsForDropDownList(test.Company_Id), "Key", "Value"); locationsList = new SelectList(new LocationsServices().GetLocationsForDropDownList(test.Company_Id), "Key", "Value"); FOTypes = new FunctionalOrganizationTypesServices().GetByCompanyToDoTest(test.Company_Id); FOTypes = new FunctionalOrganizationTypesServices().OrderByCompany(FOTypes); FOrganizations = new SelectList(new FunctionalOrganizationsServices().GetEmptyDictionary()); performanceEvaluationsList = new SelectList(new PerformanceEvaluationsServices().GetPerformanceEvaluationsForDropDownList(test.Company_Id), "Key", "Value"); _evaluationViewModel = new EvaluationViewModel(evaluation, agesList, senioritiesList, instructionLevelsList, positionLevelsList, locationsList, FOTypes, FOrganizations, performanceEvaluationsList, test, previousEvaluation); }
private IQueryable <Evaluation> GetEvaluationsByUbication(int test, int?country_id, int?state_id, int?region_id) { IQueryable <Evaluation> evaluations = new TestsServices().GetById(test).Evaluations.AsQueryable(); if (country_id.HasValue) { if (state_id.HasValue) { evaluations = evaluations.Where(l => l.Location.State_Id == state_id.Value); } else { evaluations = evaluations.Where(l => l.Location.State.Country_Id == country_id.Value); } } else if (region_id.HasValue) { evaluations = evaluations.Where(l => l.Location.Region_Id == region_id.Value); } return(evaluations); }
public List <SummaryTable> UpdateTable(int?questionnaire_id, int?category_id, int?question_id, int test_id, string demographic, int?FO_id, int?compare_id) { Test test = new TestsServices().GetById(test_id); Test testCompare = new Test(); Dictionary <string, List <string> > textAnswers = new Dictionary <string, List <string> >(); Dictionary <string, List <string> > textAnswersCompare = new Dictionary <string, List <string> >(); if (compare_id.HasValue) { testCompare = new TestsServices().GetById(compare_id.Value); } switch (demographic) { case "General": textAnswers = test.GetGeneralTextAnswers(questionnaire_id, category_id, question_id); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetGeneralTextAnswers(questionnaire_id, category_id, question_id); } break; case "Location": textAnswers = test.GetTextAnswersByLocations(questionnaire_id, category_id, question_id); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetTextAnswersByLocations(questionnaire_id, category_id, question_id); } break; case "AgeRange": textAnswers = test.GetTextAnswersByAgeRanges(questionnaire_id, category_id, question_id); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetTextAnswersByAgeRanges(questionnaire_id, category_id, question_id); } break; case "Country": textAnswers = test.GetTextAnswersByCountries(questionnaire_id, category_id, question_id); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetTextAnswersByCountries(questionnaire_id, category_id, question_id); } break; case "Region": textAnswers = test.GetTextAnswersByRegions(questionnaire_id, category_id, question_id); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetTextAnswersByRegions(questionnaire_id, category_id, question_id); } break; case "InstructionLevel": textAnswers = test.GetTextAnswersByInstructionLevels(questionnaire_id, category_id, question_id); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetTextAnswersByInstructionLevels(questionnaire_id, category_id, question_id); } break; case "PositionLevel": textAnswers = test.GetTextAnswersByPositionLevels(questionnaire_id, category_id, question_id); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetTextAnswersByPositionLevels(questionnaire_id, category_id, question_id); } break; case "Seniority": textAnswers = test.GetTextAnswersBySeniorities(questionnaire_id, category_id, question_id); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetTextAnswersBySeniorities(questionnaire_id, category_id, question_id); } break; case "Gender": textAnswers = test.GetTextAnswersByGenders(questionnaire_id, category_id, question_id); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetTextAnswersByGenders(questionnaire_id, category_id, question_id); } break; case "Performance": textAnswers = test.GetTextAnswersByPerformanceEvaluations(questionnaire_id, category_id, question_id); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetTextAnswersByPerformanceEvaluations(questionnaire_id, category_id, question_id); } break; case "FunctionalOrganizationType": textAnswers = test.GetTextAnswersByFOs(questionnaire_id, category_id, question_id, FO_id.Value); if (compare_id.HasValue) { textAnswersCompare = testCompare.GetTextAnswersByFOs(questionnaire_id, category_id, question_id, FO_id.Value); } break; } return(FillSumaryTable(textAnswers, textAnswersCompare, test, testCompare)); }
public Dictionary <int, string> GetItemsByDemographic(int test_id, string demographic, int?FO_id) { Test test = new TestsServices().GetById(test_id); Dictionary <int, string> items = new Dictionary <int, string>(); object aux; switch (demographic) { case "Location": aux = test.Evaluations.Select(i => i.Location).Distinct().OrderBy(l => l.Name).ToList(); foreach (Location obj in (List <Location>)aux) { items.Add(obj.Id, obj.Name); } break; case "AgeRange": aux = test.Evaluations.Select(i => i.Age).Distinct().OrderBy(l => l.Level).ToList(); foreach (Age obj in (List <Age>)aux) { items.Add(obj.Id, obj.Name); } break; case "Country": aux = test.Evaluations.Select(i => i.Location.State.Country).Distinct().OrderBy(l => l.Name).ToList(); foreach (Country obj in (List <Country>)aux) { items.Add(obj.Id, obj.Name); } break; case "Region": aux = test.Evaluations.Select(i => i.Location.Region).Distinct().OrderBy(l => l.Name).ToList(); foreach (Region obj in (List <Region>)aux) { items.Add(obj.Id, obj.Name); } break; case "InstructionLevel": aux = test.Evaluations.Select(i => i.InstructionLevel).Distinct().OrderBy(l => l.Level).ToList(); foreach (InstructionLevel obj in (List <InstructionLevel>)aux) { items.Add(obj.Id, obj.Name); } break; case "PositionLevel": aux = test.Evaluations.Select(i => i.PositionLevel).Distinct().OrderBy(l => l.Level).ToList(); foreach (PositionLevel obj in (List <PositionLevel>)aux) { items.Add(obj.Id, obj.Name); } break; case "Seniority": aux = test.Evaluations.Select(i => i.Seniority).Distinct().OrderBy(l => l.Level).ToList(); foreach (Seniority obj in (List <Seniority>)aux) { items.Add(obj.Id, obj.Name); } break; case "Gender": aux = test.Evaluations.Select(i => i.Sex).Distinct().OrderBy(l => l).ToList(); foreach (string obj in (List <string>)aux) { items.Add(obj.ToLower() == "female" ? 1 : 2, obj); } break; case "Performance": aux = test.Evaluations.Select(i => i.PerformanceEvaluation).Distinct().OrderBy(l => l.Level).ToList(); foreach (PerformanceEvaluation obj in (List <PerformanceEvaluation>)aux) { items.Add(obj.Id, obj.Name); } break; case "FunctionalOrganizationType": aux = test.Evaluations.Select(i => i.EvaluationFOs.Select(fo => fo.FunctionalOrganization).Where(t => t.Type_Id == FO_id.Value).OrderBy(l => l.Name)).Distinct().ToList(); foreach (FunctionalOrganization obj in (List <FunctionalOrganization>)aux) { items.Add(obj.Id, obj.Name); } break; } return(items); }