public string GetHRef(int test) { string href = "-"; List <int> countries; Dictionary <int, string> maps = new Dictionary <int, string>() { { 2, "Venezuela" }, { 23, "Argentina" }, { 61, "Colombia" }, { 247, "United States" } };; countries = new EvaluationsServices().GetCountriesByTest(test); if (countries.Count == 1 && maps.Keys.Contains(countries[0])) { href = "/Home/ClimateStateMap?country_id=" + countries.FirstOrDefault(); href = href + "&test_id=" + test; } return(href); }
//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)); }
public EvaluationsController(EvaluationsServices _evaluationService) { this._evaluationService = _evaluationService; }
private Evaluation GetEvaluationFromExisting(FormCollection collection) { Evaluation evaluation = new Evaluation(); Evaluation existing = new EvaluationsServices().GetById(int.Parse(collection["EvaluationId"])); 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 = existing.Age_Id; } if (demographics.Contains("InstructionLevel")) { evaluation.InstructionLevel_Id = existing.InstructionLevel_Id; } if (demographics.Contains("PositionLevel")) { evaluation.PositionLevel_Id = existing.PositionLevel_Id; } if (demographics.Contains("Seniority")) { evaluation.Seniority_Id = existing.Seniority_Id; } if (demographics.Contains("Location")) { evaluation.Location_Id = existing.Location_Id; } if (demographics.Contains("Performance")) { evaluation.Performance_Id = existing.Performance_Id; } if (demographics.Contains("Gender")) { evaluation.Sex = existing.Sex; } 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) { if (test.DemographicsInTests.Where(f => f.FOT_Id == v.Key).Count() == 1) { Selected_FO[0][j] = v.Key; Selected_FO[1][j] = existing.EvaluationFOs.Where(t => t.FunctionalOrganization.Type_Id == v.Key).FirstOrDefault().FunctionalOrganization_Id; // Select Functional Organization j++; } } evaluation.CreationDate = DateTime.Now; ValidateEvaluationModel(evaluation); return(evaluation); }
public EvaluationsController() { _evaluationService = new EvaluationsServices(); }