public OperationResult DeleteLocation(DeleteLocationDto deleteLocationDto) { var location = LocationRepository.GetById(deleteLocationDto.LocationId); if (location == null) { return(new OperationResult(false, "Şehir Bulunamadı.", (int)HttpStatusCode.NotFound)); } LocationRepository.DeleteAndSave(location); return(new OperationResult(true, "Şehir Silindi", (int)HttpStatusCode.OK)); }
public ActionResult DeleteLocation(DeleteLocationDto deleteLocation) { if (!ModelState.IsValid) { var locationList = _adminServices.GetLocationsDto(); ViewBag.locations = locationList.Select(x => new SelectListItem() { Text = x.LocationName, Value = x.LocationId.ToString() }); return(View(deleteLocation)); } deleteLocation.LocationId = Convert.ToInt32(deleteLocation.LocationName); _adminServices.DeleteLocation(deleteLocation); return(Redirect("/Admin")); }