| 236 | } |
| 237 | |
| 238 | pub async fn create(dp: DeviceProfile) -> Result<DeviceProfile, Error> { |
| 239 | dp.validate() |
| 240 | .map_err(|e| Error::Validation(e.to_string()))?; |
| 241 | |
| 242 | let dp: DeviceProfile = diesel::insert_into(device_profile::table) |
| 243 | .values(&dp) |
| 244 | .get_result(&mut get_async_db_conn().await?) |
| 245 | .await |
| 246 | .map_err(|e| error::Error::from_diesel(e, dp.id.to_string()))?; |
| 247 | info!(id = %dp.id, "Device-profile created"); |
| 248 | Ok(dp) |
| 249 | } |
| 250 | |
| 251 | pub async fn get(id: &Uuid) -> Result<DeviceProfile, Error> { |
| 252 | let dp = device_profile::dsl::device_profile |