コード例 #1
0
        /// <see cref="GAP.Appointments.Core.Repository.IEmployeeRepository.GetAppointments(string)"
        public async Task <bool> UpdateAppointment(AppointmenTO filtro)
        {
            //Get employees list from data source
            bool appointmentState = await AppointmentDAO.UpdateAppointment(filtro);

            return(appointmentState);
        }
コード例 #2
0
        public async Task <bool> UpdateAppointment(AppointmenTO filtro)
        {
            List <AppointmenTO> appointmentsByPacient = new List <AppointmenTO>();

            using (AppointmentsEntities dbContext = new AppointmentsEntities())
            {
                appointmentsByPacient = await(from app in dbContext.Appointments
                                              join pat in dbContext.Pacients on app.IdKeyPacient equals pat.IdKey
                                              where app.IdKeyPacient == filtro.IdKeyPacient &&
                                              app.IdKey == filtro.IdKey &&
                                              DbFunctions.DiffHours(app.Date, SqlFunctions.GetDate().Value) <= 24
                                              select app).ProjectTo <AppointmenTO>().ToListAsync();

                if (appointmentsByPacient.Count <= 0)
                {
                    Appointment AppointmentUpdate = Mapper.Map <Appointment>(filtro);
                    dbContext.Appointments.Attach(AppointmentUpdate);
                    var entry = dbContext.Entry(AppointmentUpdate);
                    entry.Property(e => e.IdState).IsModified = true;
                    // other changed properties
                    dbContext.SaveChanges();
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
        public async Task <bool> CreateAppointment(AppointmenTO filtro)
        {
            List <AppointmenTO> appointmentsByPacient = new List <AppointmenTO>();

            using (AppointmentsEntities dbContext = new AppointmentsEntities())
            {
                appointmentsByPacient = await(from app in dbContext.Appointments
                                              join pat in dbContext.Pacients on app.IdKeyPacient equals pat.IdKey
                                              join sta in dbContext.States on app.Type.IdKey equals sta.IdKey
                                              where app.IdKeyPacient == filtro.IdKeyPacient &&
                                              DbFunctions.TruncateTime(app.Date) == filtro.Date.Date &&
                                              sta.Description == "Programado"
                                              select app).ProjectTo <AppointmenTO>().ToListAsync();

                if (appointmentsByPacient.Count <= 0)
                {
                    Appointment AppointmentCreate = Mapper.Map <Appointment>(filtro);
                    dbContext.Appointments.Add(AppointmentCreate);
                    dbContext.SaveChanges();
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #4
0
        public async Task Error_CancelAppointmentLess_24_Hours_ByPacient()
        {
            var          _appointmentRepository = Container.GetInstance <IInfoAppointmentRepository>();
            AppointmenTO AppointmenTO           = new AppointmenTO();

            //types
            //1 Medicina General
            //2 Odontología
            //3 Pediatría
            //4 Neurología

            //states
            //1 Programado
            //2 Cancelado
            //3 Verificado

            //prueba error
            AppointmenTO.Date         = DateTime.Now;
            AppointmenTO.IdKey        = 6; //id appointment
            AppointmenTO.IdKeyPacient = 1; // id pacient
            AppointmenTO.IdType       = 1; //type
            AppointmenTO.IdState      = 2; //state cancel

            bool CanAddAppointment = await _appointmentRepository.UpdateAppointment(AppointmenTO);

            Assert.IsNotNull(CanAddAppointment);
            Assert.IsTrue(CanAddAppointment);
        }
コード例 #5
0
        public async Task AddAppointmentDiferentDayByPacient()
        {
            var          _appointmentRepository = Container.GetInstance <IInfoAppointmentRepository>();
            AppointmenTO AppointmenTO           = new AppointmenTO();

            //types
            //1 Medicina General
            //2 Odontología
            //3 Pediatría
            //4 Neurología

            //states
            //1 Programado
            //2 Cancelado
            //3 Verificado

            AppointmenTO.Date         = DateTime.Now;
            AppointmenTO.IdKeyPacient = 1; //
            AppointmenTO.IdType       = 1;
            AppointmenTO.IdState      = 1;

            bool CanAddAppointment = await _appointmentRepository.CreateAppointment(AppointmenTO);

            Assert.IsNotNull(CanAddAppointment);
            Assert.IsTrue(CanAddAppointment);
        }
コード例 #6
0
        public void UpdateInfoAppointmentsByPacient()
        {
            //token
            RestClient client;
            string     appointmentServiceUrl = ConfigurationManager.AppSettings["APIRoot"];

            client = new RestClient(appointmentServiceUrl);

            AppointmenTO AppointmenTO = new AppointmenTO();

            //types
            //1 Medicina General
            //2 Odontología
            //3 Pediatría
            //4 Neurología

            //states
            //1 Programado
            //2 Cancelado
            //3 Verificado

            AppointmenTO.Date         = DateTime.Now;
            AppointmenTO.IdKey        = 6; //id appointment
            AppointmenTO.IdKeyPacient = 1; // id pacient
            AppointmenTO.IdType       = 1; //type
            AppointmenTO.IdState      = 2; //state cancel

            var request = new RestRequest("UpdateAppointment", Method.POST);

            // easily add HTTP Headers
            request.AddJsonBody(AppointmenTO);

            // execute the request
            IRestResponse response = client.ExecuteAsPost(request, "POST");

            bool AddAppointmentsByPacient = JsonConvert.DeserializeObject <bool>(response.Content);

            Assert.IsNotNull(AddAppointmentsByPacient);
            Assert.IsTrue(AddAppointmentsByPacient);
        }
コード例 #7
0
        public async Task <IHttpActionResult> CreateAppointment(AppointmenTO filtro)
        {
            bool AppointmenState = await _repository.CreateAppointment(filtro);

            return(Ok(AppointmenState));
        }
コード例 #8
0
        public ActionResult UpdateAppointment(AppointmenTO filtro)
        {
            var Datos = _proxy.PostForMessage <string>(ConstantesApi.getUpdateAppointmentUri, filtro);

            return(Content(Datos.Body, "application/json"));
        }