public class CountriesController : ApiController { <pre> private MyDB db = new MyDB(); public List<SelectListItem> GetDropDownList<T>( string text, string value, string selected) where T : class { List<SelectListItem> list = new List<SelectListItem>(); list.Add(new SelectListItem { Text = "-Please select-", Value = string.Empty }); IQueryable<T> result = db.Set<T>(); var lisData = (from items in result select items).AsEnumerable().Select(m => new SelectListItem { Text = (string)m.GetType().GetProperty(text).GetValue(m), Value = (string)m.GetType().GetProperty(value).GetValue(m), Selected = (selected != "") ? ((string) m.GetType().GetProperty(value).GetValue(m) == selected ? true : false) : false, }).ToList(); list.AddRange(lisData); return list; }
public async Task<IEnumerable<TEntity>> GetAllProductAsync(string apiurl) { string apiurl = "/Api/GetCountres/'01'/'01'/'01'" IEnumerable<TEntity> TEntity = null; HttpResponseMessage response = await client.GetAsync($"{apiurl}"); if (response.IsSuccessStatusCode) { string stringData = response.Content.ReadAsStringAsync().Result; TEntity = JsonConvert.DeserializeObject<IEnumerable<TEntity>>(stringData); } return TEntity; }
How can i pass T(Entity) Value to WEB API 2 through below function note : Web api and Website in separate projects.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)