public IHttpActionResult ListLandBased(long id) { try { List<LandBasedViewModel> model = repo.GetListLandBasedInfo(id); SelectRepository selectRepo = new SelectRepository(); List<JobSpecialization> lstSpecs = selectRepo.Specializations(); List<Country> lstCountries = selectRepo.Countries(); List<Currency> lstCurrency = selectRepo.Currencies(); foreach (var e in model) { e.lstSpecializations = new System.Web.Mvc.SelectList(lstSpecs, "id", "description", e.specialization); e.lstCountries = new System.Web.Mvc.SelectList(lstCountries, "id", "name", e.country); e.lstCurrencies = new System.Web.Mvc.SelectList(lstCurrency, "id", "description", e.salary_currency); } var landEmpty = new LandBasedViewModel(); landEmpty.lstSpecializations = new System.Web.Mvc.SelectList(lstSpecs, "id", "description"); landEmpty.lstCountries = new System.Web.Mvc.SelectList(lstCountries, "id", "name"); landEmpty.lstCurrencies = new System.Web.Mvc.SelectList(lstCurrency, "id", "description"); landEmpty.job_description.Add(new JobDescription()); model.Add(landEmpty); return Ok(model); } catch (Exception ex) { return BadRequest(ex.Message); } }
public IHttpActionResult LandBasedSelect() { try { SelectRepository repo = new SelectRepository(); SelectCollectionsViewModel model = new SelectCollectionsViewModel(); model.Specializations = repo.Specializations(); model.Countries = repo.Countries(); model.Currencies = repo.Currencies(); return Ok(model); } catch (Exception ex) { return BadRequest(ex.Message); } }