public async Task <IActionResult> AssignPatientToBed([FromRoute] string id, [FromRoute] string bedId) { if (string.IsNullOrWhiteSpace(id) || string.IsNullOrWhiteSpace(bedId)) { return(BadRequest("Some id is null or empty")); } var bed = await _bedManager.GetById(bedId); if (bed == null) { return(BadRequest("Bed not found")); } var patient = await _userManager.GetById(id); if (patient == null) { return(BadRequest("Patient not found")); } bed.PatientId = patient.Id; await _bedManager.UpdateBedAsync(bed); return(Ok("Assigned")); }
public async Task <IActionResult> GetBedByIdAsync([FromRoute] string id) { if (string.IsNullOrWhiteSpace(id)) { return(BadRequest("Id is null or empty")); } var bed = await _bedManager.GetById(id); if (bed == null) { return(BadRequest("Bed not found")); } var response = _mapper.Map <BedResponse>(bed); return(Ok(response)); }