public Driver SaveDriver(Driver driver) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("name", driver.Name); parameters.Add("surname", driver.Surname); parameters.Add("dni", driver.Dni); parameters.Add("address", driver.Address); parameters.Add("loginCode", driver.LoginCode); parameters.Add("licenseNumber", driver.LicenseNumber); parameters.Add("licenseCategory", driver.LicenseCategory); parameters.Add("status", driver.Status); parameters.Add("driverId", 0); connection.ExecuteScalar("sp_add_driver", param: parameters, commandType: CommandType.StoredProcedure); var driverId = parameters.Get <Int32>("driverId"); driver.Id = driverId; return(driver); } }
public IEnumerable <Driver> GetAllDrivers() { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var drivers = connection.Query <Driver>("sp_all_drivers", commandType: CommandType.StoredProcedure); return(drivers); } }
public IEnumerable <Incidence> GetAllIncidences() { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var incidences = connection.Query <Incidence>("sp_all_incidences", commandType: CommandType.StoredProcedure); return(incidences); } }
public Driver GetDriverByLoginCode(string loginCode) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("loginCode", loginCode); var driver = connection.QuerySingle <Driver>("sp_login_driver", param: parameters, commandType: CommandType.StoredProcedure); return(driver); } }
public Driver GetDriver(int driverId) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("driverId", driverId); var driver = connection.QuerySingle <Driver>("sp_find_driver_id", param: parameters, commandType: CommandType.StoredProcedure); return(driver); } }
public Incidence GetIncidence(int incidenceId) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("incidenceId", incidenceId); var driver = connection.QuerySingle <Incidence>("sp_find_incidence_id", commandType: CommandType.StoredProcedure); return(driver); } }
public IEnumerable <Incidence> GetIncidenceByCode(int orderId) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("orderId", orderId); var incidences = connection.Query <Incidence>("sp_find_incidences_order", param: parameters, commandType: CommandType.StoredProcedure); return(incidences); } }
public bool DeleteDriver(int driverId) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("driverId", driverId); var result = connection.Execute("sp_delete_driver", param: parameters, commandType: CommandType.StoredProcedure); return(result > 0); } }
public Incidence UpdateIncidence(Incidence incidence) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("incidenceId", incidence.Id); parameters.Add("date", incidence.Date); parameters.Add("latitude", incidence.Latitude); parameters.Add("longitude", incidence.Longitude); parameters.Add("message", incidence.Message); parameters.Add("orderId", incidence.OrderId); var result = connection.Execute("sp_update_incidence", param: parameters, commandType: CommandType.StoredProcedure); return(result > 0 ? incidence : new Incidence()); } }
public Driver UpdateDriver(Driver driver) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("driverId", driver.Id); parameters.Add("name", driver.Name); parameters.Add("surname", driver.Surname); parameters.Add("dni", driver.Dni); parameters.Add("address", driver.Address); parameters.Add("loginCode", driver.LoginCode); parameters.Add("licenseNumber", driver.LicenseNumber); parameters.Add("licenseCategory", driver.LicenseCategory); parameters.Add("status", driver.Status); var result = connection.Execute("sp_update_driver", param: parameters, commandType: CommandType.StoredProcedure); return(result > 0 ? driver : new Driver()); } }
public Incidence SaveIncidence(Incidence incidence) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("date", incidence.Date); parameters.Add("latitude", incidence.Latitude); parameters.Add("longitude", incidence.Longitude); parameters.Add("message", incidence.Message); parameters.Add("orderId", incidence.OrderId); parameters.Add("incidenceId", 0); connection.ExecuteScalar("sp_add_incidence", param: parameters, commandType: CommandType.StoredProcedure); var incidenceId = parameters.Get <Int32>("incidenceId"); incidence.Id = incidenceId; return(incidence); } }