public async Task <LabExamination> UpdateAsync(LabExamination labExamination)
        {
            var result = context.LabExaminations.Update(labExamination);
            await context.SaveChangesAsync();

            return(result.Entity);
        }
        public async Task <IActionResult> CreateLabExaminationAsync(CreateLabExaminationDto labExaminationDto)
        {
            var examinationCode =
                await examinationCodeRepository.GetAsync(labExaminationDto.ExaminationCodeId);

            if (examinationCode == null)
            {
                return(new JsonResult(new ExceptionDto {
                    Message = "No examination with given code was found"
                })
                {
                    StatusCode = 422
                });
            }

            var appointment = await appointmentRepository.GetAsync(labExaminationDto.AppointmentId);

            if (appointment == null)
            {
                return(new JsonResult(new ExceptionDto {
                    Message = "Could not find the appointment"
                })
                {
                    StatusCode = 422
                });
            }

            var labExamination = new LabExamination
            {
                Appointment = appointment, ExaminationCode = examinationCode, Status = ExaminationStatus.Scheduled, IssueDate = System.DateTime.Now, DoctorRemarks = labExaminationDto.DoctorRemarks
            };

            await labExaminationRepository.AddAsync(labExamination);

            appointment.LabExaminations.Add(labExamination);
            await appointmentRepository.UpdateAsync(appointment);

            return(new JsonResult(labExamination)
            {
                StatusCode = 200
            });
        }