Ejemplo n.º 1
0
        public ServiceResponse <bool> CreateAppointment(Appointment appointment)
        {
            var now = DateTime.UtcNow;

            try
            {
                var appoint = new Appointment
                {
                    CreatedOn       = now,
                    UpdatedOn       = now,
                    IsFirstTime     = appointment.IsFirstTime,
                    IsSick          = appointment.IsSick,
                    AppointmentType = appointment.AppointmentType,
                };

                _db.Appointment.Add(appoint);

                _db.SaveChangesAsync();
            }
            catch (Exception e)
            {
                return(new ServiceResponse <bool>
                {
                    Data = false,
                    Message = e.StackTrace,
                    Time = now,
                    IsSuccess = false
                });
            }

            return(new ServiceResponse <bool>
            {
                Data = false,
                Message = "Could not create an appointment",
                Time = now,
                IsSuccess = false
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a patient and save to the system
        /// </summary>
        /// <param name="patient"></param>
        /// <returns></returns>
        public async Task <ServiceResponse <bool> > CreatePatient(Patient patient)
        {
            var now = DateTime.UtcNow;

            try
            {
                if (patient == null)
                {
                    return(new ServiceResponse <bool>
                    {
                        Message = "Patient Model is null",
                        IsSuccess = false,
                        Time = now,
                        Data = false
                    });
                }
                patient.CreatedOn = now;
                patient.UpdatedOn = now;

                _db.Patients.Add(patient);
                await _db.SaveChangesAsync();

                return(new ServiceResponse <bool>
                {
                    IsSuccess = true,
                    Data = true,
                    Message = $"Patient with Id {patient.Id} created successfully!",
                    Time = now
                });
            }
            catch (Exception e)
            {
                return(new ServiceResponse <bool>
                {
                    Data = false,
                    Message = e.StackTrace,
                    IsSuccess = false,
                    Time = now
                });
            }
        }