public long CreateNewAirline(LoginToken <Administrator> token, AirlineCompany airline) { long airlineID = 0; if (token != null && token.User != null) { airlineID = _airlineDAO.Add(airline); airline.ID = airlineID; } return(airlineID); }
public void ChangeMyPassword(LoginToken <AirlineCompany> token, AirlineCompany airline, string oldPassword, string newPassword) { if (token != null && token.User != null) { if (airline.Password == oldPassword) { airline.Password = newPassword; _airlineDAO.Update(airline); } } }
public void Remove(AirlineCompany airlineCompany) { //ALTER PROCEDURE[dbo].[REMOVE_AIRLINE] //@ID bigint //AS //delete from AirlineCompanies where ID = @ID; using (SqlConnection connection = new SqlConnection(flightCenterConfig.CONNECTION_STRING)) { SqlCommand cmd = new SqlCommand("REMOVE_AIRLINE", connection); cmd.Parameters.Add(new SqlParameter("@ID", airlineCompany.ID)); connection.Open(); cmd.CommandType = CommandType.StoredProcedure; //cmd.EndExecuteNonQuery(); -----do i need this also if i use stored procedure? SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default); } }
public void Update(AirlineCompany airlineCompany) { //ALTER PROCEDURE[dbo].[UPDATE_AIRLINE] @ID bigint, @AIRLINE_NAME varchar(1000), @USER_NAME varchar(1000), @PASSWORD varchar(1000), @COUNTRY_CODE bigint //AS //update AirlineCompanies //set AIRLINE_NAME = @AIRLINE_NAME, USER_NAME = @USER_NAME, PASSWORD = @PASSWORD, COUNTRY_CODE= @COUNTRY_CODE //where ID = @ID using (SqlConnection connection = new SqlConnection(flightCenterConfig.CONNECTION_STRING)) { SqlCommand cmd = new SqlCommand("UPDATE_AIRLINE", connection); cmd.Parameters.Add(new SqlParameter("@ID", airlineCompany.ID)); cmd.Parameters.Add(new SqlParameter("@AIRLINE_NAME", airlineCompany.AirlineName)); cmd.Parameters.Add(new SqlParameter("@USER_NAME", airlineCompany.UserName)); cmd.Parameters.Add(new SqlParameter("@PASSWORD", airlineCompany.Password)); cmd.Parameters.Add(new SqlParameter("@COUNTRY_CODE", airlineCompany.CountryCode)); connection.Open(); cmd.CommandType = CommandType.StoredProcedure; //cmd.EndExecuteNonQuery(); -----do i need this also if i use stored procedure? SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default); } }
public long Add(AirlineCompany airlineCompany) { //ALTER PROCEDURE[dbo].[ADD_AIRLINE_COMPANY] @AIRLINE_NAME varchar(1000), @USER_NAME varchar(1000), @PASSWORD varchar(1000), @COUNTRY_CODE bigint //AS //insert into AirlineCompanies(AIRLINE_NAME, USER_NAME, PASSWORD , COUNTRY_CODE) //VALUES //(@AIRLINE_NAME, @USER_NAME, @PASSWORD, @COUNTRY_CODE); //select ID from AirlineCompanies long airlineCompanyIdFromDB; using (SqlConnection connection = new SqlConnection(flightCenterConfig.CONNECTION_STRING)) { SqlCommand cmd = new SqlCommand("ADD_AIRLINE_COMPANY", connection); cmd.Parameters.Add(new SqlParameter("@AIRLINE_NAME", airlineCompany.AirlineName)); cmd.Parameters.Add(new SqlParameter("@USER_NAME", airlineCompany.UserName)); cmd.Parameters.Add(new SqlParameter("@PASSWORD", airlineCompany.Password)); cmd.Parameters.Add(new SqlParameter("@COUNTRY_CODE", airlineCompany.CountryCode)); connection.Open(); cmd.CommandType = CommandType.StoredProcedure; airlineCompanyIdFromDB = (long)cmd.ExecuteScalar(); } return((long)airlineCompanyIdFromDB); }
public void Add(AirlineCompany airlineCompany) { //ALTER PROCEDURE[dbo].[ADD_AIRLINE_COMPANY] @AIRLINE_NAME varchar(1000), @USER_NAME varchar(1000), @PASSWORD varchar(1000), @COUNTRY_CODE bigint //AS //insert into AirlineCompanies(AIRLINE_NAME, USER_NAME, PASSWORD , COUNTRY_CODE) //VALUES //(@AIRLINE_NAME, @USER_NAME, @PASSWORD, @COUNTRY_CODE); using (SqlConnection connection = new SqlConnection(flightCenterConfig.CONNECTION_STRING)) { SqlCommand cmd = new SqlCommand("ADD_AIRLINE_COMPANY", connection); cmd.Parameters.Add(new SqlParameter("@AIRLINE_NAME", airlineCompany.AirlineName)); cmd.Parameters.Add(new SqlParameter("@USER_NAME", airlineCompany.UserName)); cmd.Parameters.Add(new SqlParameter("@PASSWORD", airlineCompany.Password)); cmd.Parameters.Add(new SqlParameter("@COUNTRY_CODE", airlineCompany.CountryCode)); connection.Open(); cmd.CommandType = CommandType.StoredProcedure; //cmd.EndExecuteNonQuery(); -----do i need this also if i use stored procedure? SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default); cmd.Connection.Close(); } }