public IHttpActionResult ListSeaBased(long id) { try { List<SeaBasedViewModel> model = repo.GetListSeaBasedInfo(id); SelectRepository selectRepo = new SelectRepository(); List<JobSpecialization> lstSpecs = selectRepo.Specializations(); List<VesselType> lstVessels = selectRepo.VesselTypes(); List<TradeArea> lstTradeAreas = selectRepo.TradeAreas(); List<EngineType> lstEngines = selectRepo.EngineTypes(); List<Currency> lstCurrencies = selectRepo.Currencies(); foreach (var e in model) { e.lstSpecializations = new System.Web.Mvc.SelectList(lstSpecs, "id", "description", e.specialization); e.lstCurrencies = new System.Web.Mvc.SelectList(lstCurrencies, "id", "description", e.salary_currency); e.lstVesselTypes = new System.Web.Mvc.SelectList(lstVessels, "id", "description", e.vessel_type); e.lstTradeAreas = new System.Web.Mvc.SelectList(lstTradeAreas, "id", "description", e.trade_area); e.lstEngineTypes = new System.Web.Mvc.SelectList(lstEngines, "id", "description", e.engine_type); } var seaEmpty = new SeaBasedViewModel(); seaEmpty.lstSpecializations = new System.Web.Mvc.SelectList(lstSpecs, "id", "description"); seaEmpty.lstCurrencies = new System.Web.Mvc.SelectList(lstCurrencies, "id", "description"); seaEmpty.lstVesselTypes = new System.Web.Mvc.SelectList(lstVessels, "id", "description"); seaEmpty.lstVesselTypes = new System.Web.Mvc.SelectList(lstVessels, "id", "description"); seaEmpty.lstTradeAreas = new System.Web.Mvc.SelectList(lstTradeAreas, "id", "description"); seaEmpty.lstEngineTypes = new System.Web.Mvc.SelectList(lstEngines, "id", "description"); seaEmpty.job_description.Add(new JobDescription()); model.Add(seaEmpty); return Ok(model); } catch (Exception ex) { return BadRequest(ex.Message); } }
public IHttpActionResult SeaBasedSelect() { try { SelectRepository repo = new SelectRepository(); SelectCollectionsViewModel model = new SelectCollectionsViewModel(); model.Specializations = repo.Specializations(); model.Vessels = repo.VesselTypes(); model.TradeAreas = repo.TradeAreas(); model.EngineTypes = repo.EngineTypes(); model.Currencies = repo.Currencies(); return Ok(model); } catch (Exception ex) { return BadRequest(ex.Message); } }