public static MetroLocation GetMetroLocationByMetroLocationID(int MetroLocationID) { MetroLocation metroLocation = new MetroLocation(); SqlMetroLocationProvider sqlMetroLocationProvider = new SqlMetroLocationProvider(); metroLocation = sqlMetroLocationProvider.GetMetroLocationByMetroLocationID(MetroLocationID); return metroLocation; }
public ActionResult AddMetro(int _Busnumber, string busLines, string CityName, string zone, string Name) { City city = new City() { CityName = CityName }; int cityID = CheckPostCity(city); Stations stations = new Stations() { Type = "Metro", Name = Name, zone = zone, cityID = cityID }; int stationId = CheckPostStation(stations); string[] _Lines = busLines.Split(','); for (int i = 0; i < _Lines.Length - 1; i++) { MetroLocation metro = new MetroLocation(); metro.MetroNumber = _Busnumber; metro.Source = _Lines[i]; metro.Destination = _Lines[i + 1]; metro.stationId = stationId; HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:65046/"); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var respond = client.PostAsJsonAsync <MetroLocation>($"Moslah/Metro/CreateMetro", metro).Result; } return(View("Index")); }
public static MetroLocation GetMetroLocationByMetroLocationID(int MetroLocationID) { MetroLocation metroLocation = new MetroLocation(); SqlMetroLocationProvider sqlMetroLocationProvider = new SqlMetroLocationProvider(); metroLocation = sqlMetroLocationProvider.GetMetroLocationByMetroLocationID(MetroLocationID); return(metroLocation); }
public IHttpActionResult Post(MetroLocation metro)//Add new bus { if (ListOfMetro.FirstOrDefault(m => m.MetroNumber == metro.MetroNumber) == null) { DB.metroLocations.Add(metro); DB.SaveChanges(); return(Ok()); } return(NotFound()); }
public IHttpActionResult DeleteMetro(int metroNo)// deleteByBusNo. { MetroLocation MetroLocation = ListOfMetro.FirstOrDefault(s => s.MetroNumber == metroNo); if (MetroLocation == null) { return(NotFound()); } DB.metroLocations.Remove(MetroLocation); DB.SaveChanges(); return(Ok()); }
public bool UpdateMetroLocation(MetroLocation metroLocation) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("UpdateMetroLocation", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MetroLocationID", SqlDbType.Int).Value = metroLocation.MetroLocationID; cmd.Parameters.Add("@MetroLocationName", SqlDbType.NVarChar).Value = metroLocation.MetroLocationName; cmd.Parameters.Add("@State", SqlDbType.NVarChar).Value = metroLocation.State; connection.Open(); int result = cmd.ExecuteNonQuery(); return(result == 1); } }
public int InsertMetroLocation(MetroLocation metroLocation) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("InsertMetroLocation", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MetroLocationID", SqlDbType.Int).Direction = ParameterDirection.Output; cmd.Parameters.Add("@MetroLocationName", SqlDbType.NVarChar).Value = metroLocation.MetroLocationName; cmd.Parameters.Add("@State", SqlDbType.NVarChar).Value = metroLocation.State; connection.Open(); int result = cmd.ExecuteNonQuery(); return((int)cmd.Parameters["@MetroLocationID"].Value); } }
public IHttpActionResult PutMetro(int metronum, MetroLocation metro)//Add new bus { MetroLocation metroedit = DB.metroLocations.FirstOrDefault(m => m.MetroNumber == metronum); if (metroedit == null) { return(NotFound()); } metroedit.MetroNumber = metro.MetroNumber; metroedit.Destination = metro.Destination; metroedit.Source = metro.Source; metroedit.Stations = metro.Stations; metroedit.PriceMetro = metro.PriceMetro; DB.SaveChanges(); return(Ok()); }
public MetroLocation GetMetroLocationFromReader(IDataReader reader) { try { MetroLocation metroLocation = new MetroLocation ( DataAccessObject.IsNULL <int>(reader["MetroLocationID"]), DataAccessObject.IsNULL <string>(reader["MetroLocationName"]), DataAccessObject.IsNULL <string>(reader["State"]) ); return(metroLocation); } catch (Exception ex) { return(null); } }
public static bool UpdateMetroLocation(MetroLocation metroLocation) { SqlMetroLocationProvider sqlMetroLocationProvider = new SqlMetroLocationProvider(); return(sqlMetroLocationProvider.UpdateMetroLocation(metroLocation)); }
public static int InsertMetroLocation(MetroLocation metroLocation) { SqlMetroLocationProvider sqlMetroLocationProvider = new SqlMetroLocationProvider(); return(sqlMetroLocationProvider.InsertMetroLocation(metroLocation)); }
public MetroLocation GetMetroLocationFromReader(IDataReader reader) { try { MetroLocation metroLocation = new MetroLocation ( DataAccessObject.IsNULL<int>(reader["MetroLocationID"]), DataAccessObject.IsNULL<string>(reader["MetroLocationName"]), DataAccessObject.IsNULL<string>(reader["State"]) ); return metroLocation; } catch(Exception ex) { return null; } }
public bool UpdateMetroLocation(MetroLocation metroLocation) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("UpdateMetroLocation", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MetroLocationID", SqlDbType.Int).Value = metroLocation.MetroLocationID; cmd.Parameters.Add("@MetroLocationName", SqlDbType.NVarChar).Value = metroLocation.MetroLocationName; cmd.Parameters.Add("@State", SqlDbType.NVarChar).Value = metroLocation.State; connection.Open(); int result = cmd.ExecuteNonQuery(); return result == 1; } }
public int InsertMetroLocation(MetroLocation metroLocation) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("InsertMetroLocation", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MetroLocationID", SqlDbType.Int).Direction = ParameterDirection.Output; cmd.Parameters.Add("@MetroLocationName", SqlDbType.NVarChar).Value = metroLocation.MetroLocationName; cmd.Parameters.Add("@State", SqlDbType.NVarChar).Value = metroLocation.State; connection.Open(); int result = cmd.ExecuteNonQuery(); return (int)cmd.Parameters["@MetroLocationID"].Value; } }
public static bool UpdateMetroLocation(MetroLocation metroLocation) { SqlMetroLocationProvider sqlMetroLocationProvider = new SqlMetroLocationProvider(); return sqlMetroLocationProvider.UpdateMetroLocation(metroLocation); }
public static int InsertMetroLocation(MetroLocation metroLocation) { SqlMetroLocationProvider sqlMetroLocationProvider = new SqlMetroLocationProvider(); return sqlMetroLocationProvider.InsertMetroLocation(metroLocation); }