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> UpdateBedAsync([FromRoute] string id, [FromBody] UpdateBedRequest updateBedRequest) { if (string.IsNullOrWhiteSpace(id)) { return(BadRequest("Id is null or empty")); } if (!string.Equals(id, updateBedRequest.BedId, System.StringComparison.OrdinalIgnoreCase)) { return(BadRequest("Inconsistency in Beds id's")); } var model = _mapper.Map <BedModel>(updateBedRequest); var result = await _bedManager.UpdateBedAsync(model); if (!result) { return(BadRequest("Bed not found")); } var response = _mapper.Map <UpdateBedResponse>(model); return(Ok(response)); }