public async Task <ActionResult> Search(string origin = null, string gender = "Any") { SearchModel model = new SearchModel(); NameClient nameClient = new NameClient(_connectionOptions); NameResponse[] names = (await nameClient.GetDetailedNames(origin, gender)).ToArray(); model.Names = names.Select(response => ConvertNameResponseToModel(response)).ToArray(); return(View("_Search", model)); }
public async Task <ActionResult> Index(string origin = null, string gender = "Any") { IndexModel model = new IndexModel(origin, gender); NameClient nameClient = new NameClient(_connectionOptions); CategoryResponse[] categories = (await nameClient.GetCategories()).ToArray(); model.Categories = categories.Select(response => ConvertCategoryResponseToModel(response)).ToArray(); if (!String.IsNullOrEmpty(origin)) { model.Search = new SearchModel(); NameResponse[] names = (await nameClient.GetDetailedNames(origin, gender)).ToArray(); model.Search.Names = names.Select(response => ConvertNameResponseToModel(response)).ToArray(); } return(View("Index", model)); }