public async Task <bool> UpdateRoom(RoomPOCO room) { var roomToChange = _roomRepository.Find(r => r.RoomId.Equals(room.RoomId)).First(); //TO DO : Implement check if room can be changed - only if there is no upcoming examination booked in that room await _roomRepository.Delete(roomToChange); if (await _roomRepository.Create(_mapper.Map <RoomPOCO, Room>(room))) { return(true); } return(false); }
public async Task <bool> AddRoomToClinic(RoomPOCO room) { room.RoomId = Guid.NewGuid(); try { await _roomRepository.Create(_mapper.Map <RoomPOCO, Room>(room)); return(true); } catch (Exception e) { throw e; } }
public async Task <bool> DeleteRoom(RoomPOCO room) { var examinationsInRoom = _examinationRepository.Find(examination => examination.RoomId.Equals(room.RoomId)).ToList(); foreach (Examination examination in examinationsInRoom) { if (examination.Status.Equals(ExaminationStatus.Accepted)) { return(false); } } await _roomRepository.Delete(_mapper.Map <RoomPOCO, Room>(room)); return(true); }