private async Task <List <CityListViewModel> > GetItemsAsync() { List <CityListViewModel> list = _repository.GetCities() .Select(p => ModelFactory.Create(p)) .ToList(); return(list); }
public async Task <IActionResult> RemoveCity(int Id) { if (Id > 0) { var cities = _repository.GetCities(); var toDelete = cities.Find(p => p.CityId == Id); _repository.Remove(toDelete); if (await _repository.Save()) { return(Json(true)); } else { return(Json(false)); } } return(Json(false)); }