Пример #1
0
        /// <summary>
        /// Sets the patient to status handled.
        /// </summary>
        /// <param name="patient">The patient.</param>
        /// <exception cref="QNomy.SQL.Exceptions.GeneralDbException">
        /// </exception>
        public async Task SetPatientHandled(IPatient patient)
        {
            try
            {
                var currentPatient = await this.dbContext.Patients.FindAsync(patient.TicketNumber);

                if (currentPatient == null)
                {
                    throw new GeneralDbException(ApplicationMessages.PatientIsNotFound(patient));
                }

                currentPatient.Handled = true;

                this.dbContext.Patients.Update(currentPatient);

                await this.dbContext.SaveChangesAsync();
            }
            catch (GeneralDbException expDb)
            {
                // It was thrown above in 'not found scenario'
                throw;
            }
            catch (Exception exp)
            {
                throw new GeneralDbException(ApplicationMessages.GeneralDbExceptionMessage(), exp);
            }
        }
Пример #2
0
        /// <summary>
        /// Adds the patient.
        /// </summary>
        /// <param name="patient">The patient.</param>
        /// <returns></returns>
        /// <exception cref="QNomy.SQL.Exceptions.GeneralDbException"></exception>
        public async Task <IPatient> AddPatient(IPatient patient)
        {
            try
            {
                var result = await this.dbContext.Patients.AddAsync(patient as Patient);

                await this.dbContext.SaveChangesAsync();

                return(result.Entity);
            }
            catch (Exception exp)
            {
                throw new GeneralDbException(ApplicationMessages.GeneralDbExceptionMessage(), exp);
            }
        }
Пример #3
0
        /// <summary>
        /// Gets all patients.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="GeneralDbException"></exception>
        public async Task <IEnumerable <IPatient> > GetAllPatients(int pageIndex = 1, int pageSize = 10)
        {
            try
            {
                var result = await this.dbContext.Patients.ActualPatients()
                             .Skip((pageIndex - 1) * pageSize)
                             .Take(pageSize)
                             .ToListAsync();

                return(result.AssureNotNull());
            }
            catch (Exception ex)
            {
                throw new GeneralDbException(ApplicationMessages.GeneralDbExceptionMessage(), ex);
            }
        }