public DeviceProfileConnection GetByBoth(DeviceProfileConnection device) { DeviceProfileConnection result = new DeviceProfileConnection(); using (SqlConnection connection = new SqlConnection(Connection.String)) { SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "DeviceProfileConFindByBoth"; command.Parameters.Add(new SqlParameter("@DeviceID", device.DeviceID)); command.Parameters.Add(new SqlParameter("@ProfileID", device.ProfileID)); connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { result = Mapentity(reader); } } } return(result); }
private DeviceProfileConnection Mapentity(SqlDataReader data) { DeviceProfileConnection result = new DeviceProfileConnection(); result.DeviceID = data["DeviceID"].ToString(); result.ProfileID = data["ProfileID"].ToString(); return(result); }
public DeviceProfileConnection GetByBoth([FromBody] DeviceProfileConnection entity) { ResponseMessage <DeviceProfileConnection> request = _deviceProfileConnectionService.GetByBoth(entity); if (request == null || !request.IsSuccess || request.ResponseObject == null) { throw new Exception(request.ErrorMessage); } return(request.ResponseObject); }
public DeviceProfileConnection Create([FromBody] DeviceProfileConnection entity) { ResponseMessage <DeviceProfileConnection> request = _deviceProfileConnectionService.Create(entity); if (!request.IsSuccess) { throw new Exception(request.ErrorMessage); } return(request.ResponseObject); }
public ResponseMessage <DeviceProfileConnection> Create(DeviceProfileConnection entity) { ResponseMessage <DeviceProfileConnection> response = new ResponseMessage <DeviceProfileConnection>(); try { response.ResponseObject = _deviceProfileConnectionRepository.Create(entity); response.IsSuccess = true; response.ErrorMessage = "Success"; } catch (Exception ex) { response.IsSuccess = false; response.ErrorMessage = ex.Message; } return(response); }
public DeviceProfileConnection Create(DeviceProfileConnection entity) { using (SqlConnection connection = new SqlConnection(Connection.String)) { SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "DeviceProfileConCreate"; command.Parameters.Add(new SqlParameter("@DeviceID", entity.DeviceID)); command.Parameters.Add(new SqlParameter("@ProfileID", entity.ProfileID)); connection.Open(); int result = (int)command.ExecuteNonQuery(); if (result < 1) { throw new Exception("Error in CreateDevice stored procedure."); } return(entity); } }