public async Task <Unit> Handle(DeletePatientCommand request, CancellationToken cancellationToken)
            {
                var c = dbContext.PatientRecords.Find(request.patientID);

                if (c != null)
                {
                    dbContext.PatientRecords.Remove(c);

                    await dbContext.SaveChangesAsync();
                }

                return(Unit.Value);
            }
            async Task <PatientRecords> IRequestHandler <AddPatientCommand, PatientRecords> .Handle(AddPatientCommand request, CancellationToken cancellationToken)
            {
                PatientRecords _registerPatient = new PatientRecords
                {
                    LastName   = request.patientID.LastName,
                    FirstName  = request.patientID.FirstName,
                    MiddleName = request.patientID.MiddleName,
                    diseases   = request.patientID.diseases
                };

                dbContext.PatientRecords.Add(_registerPatient);
                await dbContext.SaveChangesAsync();

                return(_registerPatient);
            }
Ejemplo n.º 3
0
            public async Task <PatientRecords> Handle(AddPatientDiagnosisCommand request, CancellationToken cancellationToken)
            {
                var c = dbContext.PatientRecords.Find(request.PatientID);

                if (c == null)
                {
                    throw new Exception("Patient not found!");
                }

                c.diseases = request.Diseases;

                await dbContext.SaveChangesAsync();

                return(c);
            }
            public async Task <PatientRecords> Handle(UpdatePatientRecordCommand request, CancellationToken cancellationToken)
            {
                var c = dbContext.PatientRecords.Find(request.patientID.ID);

                if (c == null)
                {
                    throw new Exception("Patient not found!");
                }
                else
                {
                    c.LastName   = request.patientID.LastName;
                    c.FirstName  = request.patientID.FirstName;
                    c.MiddleName = request.patientID.MiddleName;
                }



                await dbContext.SaveChangesAsync();

                return(c);
            }