コード例 #1
0
        public async Task <Unit> Handle(CreateScheduleCommand request, CancellationToken cancellationToken)
        {
            var entity = new Domain.Entities.Schedule
            {
                Title = request.Title,
                Line  = request.Line,
                Date  = request.Date
            };

            _context.Schedules.Add(entity);

            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
コード例 #2
0
            public async Task <Unit> Handle(CreateScheduleCommand request, CancellationToken cancellationToken)
            {
                var entity = new Domain.Entities.Schedule
                {
                    VeterinaryId = request.VeterinaryId,
                    AnimalId     = request.AnimalId,
                    ScheduleDate = request.ScheduleDate
                };

                _context.Schedules.Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #3
0
        public void Integration_update_patient_fail(string name, string phone, string messageError, HttpStatusCode errorMethod)
        {
            PatientTests patientTests = new PatientTests();

            Domain.Entities.Patient patientToBeUpdate = patientTests.loadPatientFromFile("PatientFull_real_updated_fromDB.json", "", "");

            if (phone == "11999999999")
            {
                Domain.Entities.Schedule newSchedule = new Domain.Entities.Schedule(DateTime.Now.AddDays(-1), false, "", false, 50, new DateTime(), false, "--Nenhum--", "--Nenhum--", 0, 0);
                newSchedule.SetKeyNull();
                patientToBeUpdate.Schedules.Add(newSchedule);
            }
            else if (phone == "11888888888")
            {
                //schedule já existente em outro registro
                Domain.Entities.Schedule newSchedule = new Domain.Entities.Schedule(new DateTime(2021, 5, 10, 18, 30, 0, DateTimeKind.Utc), false, "", false, 50, new DateTime(), false, "--Nenhum--", "--Nenhum--", 0, 0);
                newSchedule.SetKeyNull();
                patientToBeUpdate.Schedules.Add(newSchedule);
            }
            else if (phone == "11777777777")
            {
                //tenta alterar um schedule já existente em horario já utilizado por outro registro
                Domain.Entities.Schedule newSchedule = new Domain.Entities.Schedule(new DateTime(2021, 5, 20, 18, 40, 0, DateTimeKind.Utc), false, "", false, 50, new DateTime(), false, "--Nenhum--", "--Nenhum--", 0, 0);
                patientToBeUpdate.Schedules.Add(newSchedule);
            }
            else if (phone == "11666666666")
            {
                //tenta alterar um schedule já existente em horario já utilizado por outro registro
                Domain.Entities.Schedule newSchedule = new Domain.Entities.Schedule(new DateTime(2021, 5, 20, 18, 0, 0, DateTimeKind.Utc), false, "", false, 50, new DateTime(), false, "--Nenhum--", "--Nenhum--", 0, 0);
                patientToBeUpdate.Schedules.Add(newSchedule);
            }
            else
            {
                patientToBeUpdate.SetNamePhone(name, phone);
                // .Name = name;
                //patientToBeUpdate.Phone = phone;
            }

            var responseInfo = this.UpdatenResult(patientToBeUpdate);

            var messageResult = responseInfo.Content.ReadAsStringAsync().Result;

            Assert.Equal(errorMethod, responseInfo.StatusCode);
            Assert.True(messageResult.ToLower().Contains(messageError));
        }