public ActionResult GetEducationByUser() { var iduser = RouteData.Values["id"].ToString(); ZonaFl.Business.SubSystems.SUser usern = new Business.SubSystems.SUser(); List <Persistence.Entities.Education> educations = usern.GetEducationByUser(iduser); Models.Education educationsm = new Education(); SCountry sco = new SCountry(); int i = 0; foreach (var edu in educations) { if (i == 0) { int contry = edu.Country != null?(int)edu.Country:-1; educationsm.Institution = edu.Institution; educationsm.Country = edu.Country != null?sco.FindCountrybyId(contry).Name : ""; educationsm.DateEndE = edu.DateEnd.ToString(); educationsm.DateIniE = edu.DateIni.ToString(); educationsm.Actually = edu.Actually == null? false : (bool)edu.Actually; educationsm.Title = edu.Title; educationsm.UserId = iduser; } if (i == 1) { int contry2 = edu.Country != null ? (int)edu.Country : -1; educationsm.Institution2 = edu.Institution; educationsm.Country2 = edu.Country != null?sco.FindCountrybyId(contry2).Name : ""; educationsm.DateEnd2E = edu.DateEnd.ToString(); educationsm.DateIni2E = edu.DateIni.ToString(); educationsm.Actually2 = edu.Actually == null ? false : (bool)edu.Actually; educationsm.Title2 = edu.Title; } if (i == 2) { int contry3 = edu.Country != null ? (int)edu.Country : -1; educationsm.Institution3 = edu.Institution; educationsm.Country3 = edu.Country != null?sco.FindCountrybyId(contry3).Name : ""; educationsm.DateEnd3E = edu.DateEnd.ToString(); educationsm.DateIni3E = edu.DateIni.ToString(); educationsm.Actually3 = edu.Actually == null ? false : (bool)edu.Actually; educationsm.Title3 = edu.Title; } i += 1; } return(Json(educationsm, JsonRequestBehavior.AllowGet)); }
public ActionResult Get(string SelectedCountryId) { List <Models.Country> countrylist = new List <Models.Country>(); SCountry sco = new SCountry(); List <Country> countries = sco.FindAll(); Country countryr = sco.FindCountrybyId(int.Parse(SelectedCountryId)); Models.Country countrym = new Models.Country(); countrym.CountryID = countryr.Id; countrym.CountryName = countryr.Name; //var ret = countries.Select(x => new { x.Id, x.Name }).ToList(); foreach (Country country in countries) { //if (country.Id == countryr.Id) //{ countrylist.Add(new Models.Country() { CountryID = country.Id, CountryName = country.Name, //Selected = true }); //} //else //{ //countrylist.Add(new Models.Country() //{ // CountryID = country.Id, // CountryName = country.Name, // Selected = false //}); //} } //countrylist.Insert(0, countrym); return(this.Json(countrylist, JsonRequestBehavior.AllowGet)); //return new JsonResult { Data = countrylist, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }