public DataTablesResult<CityViewModel> GetAllCities(DataTablesParam dataTableParam) { var svc = new GeoCityAppService(); var lst = svc.GetAllGeoCity(); var lstVm = new List<CityViewModel>(); foreach (var itm in lst) { var itmVm = new CityViewModel { GeoCountryName = itm.GeoState.GeoCountry.Name, GeoStateName = itm.GeoState.Name, Name = itm.Name, GeoCountryId = itm.GeoState.GeoCountry.GeoCountryId, GeoStateId = itm.GeoState.GeoStateId, GeoCityId = itm.GeoCityId }; if (itm.Latitude != null) { itmVm.Latitude = itm.Latitude; itmVm.LatitudeText = GeoAngle.FromDouble((double)itm.Latitude).ToString(); } else { itmVm.Latitude = 0; itmVm.LatitudeText = "Sín Coordenadas"; } if (itm.Longitude != null) { itmVm.Longitude = 0; itmVm.LongitudeText = GeoAngle.FromDouble((double)itm.Longitude).ToString(); } else { itmVm.Longitude = 0; itmVm.LongitudeText = "Sín Coordenadas"; } var sb = new StringBuilder(); string editUrl = Url.Action("Edit", "City"); sb.AppendLine("<div class=\"btn-group\">"); sb.AppendLine( "<button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\" aria-expanded=\"false\">"); sb.AppendLine("Acciones <span class=\"caret\"></span>"); sb.AppendLine("</button>"); sb.AppendLine("<ul class=\"dropdown-menu\" role=\"menu\">"); sb.AppendLine("<li><a href=\"" + editUrl + "?id=-1\"><i class=\"fa fa-plus\"></i> Nueva Ciudad</a></li>"); sb.AppendLine("<li><a href=\"" + editUrl + "?id=" + itmVm.GeoCityId + "\"><i class=\"fa fa-edit\"></i> Editar " + itmVm.Name + "</a></li>"); sb.AppendLine("</ul>"); sb.AppendLine("</div>"); var actionButton = sb.ToString(); itmVm.ActionButton = actionButton; lstVm.Add(itmVm); } var lstVmQueryable = lstVm.AsQueryable(); return DataTablesResult.Create(lstVmQueryable, dataTableParam); }