예제 #1
0
        static void Main(string[] args)
        {
            PetValidator petValidator = new PetValidator();
            string petsFilename = "..\\..\\..\\data\\pets.txt";
            PetsRepository petsRepository = new PetsRepository(petValidator, petsFilename);

            CustomerValidator customerValidator = new CustomerValidator();
            string customersFilename = "..\\..\\..\\data\\customers.txt";
            CustomersRepository customersRepository = new CustomersRepository(customerValidator, customersFilename);

            ServiceValidator serviceValidator = new ServiceValidator();
            string servicesFilename = "..\\..\\..\\data\\services.txt";
            ServicesRepository servicesRepository = new ServicesRepository(serviceValidator, servicesFilename);

            VetValidator vetValidator = new VetValidator();
            string vetsFilename = "..\\..\\..\\data\\vets.txt";
            VetsRepository vetsRepository = new VetsRepository(vetValidator, vetsFilename);

            AppointmentValidator appointmentValidator = new AppointmentValidator();
            string appointmentsFilename = "..\\..\\..\\data\\appointments.txt";
            AppointmentsRepository appointmentsRepository = new AppointmentsRepository(appointmentValidator, appointmentsFilename);

            Controller controller = new Controller(petsRepository, customersRepository, servicesRepository, vetsRepository,appointmentsRepository);

            runApp(controller);

        }
예제 #2
0
        public JsonResult CreateAppointment(string employeeID, string clinicId, string poliId, string doctorId, string necesity, string AppointmentDate, string MCUPackage)
        {
            var response = new AppointmentResponse();
            var _model   = new AppointmentModel
            {
                AppointmentDate = CommonUtils.ConvertStringDate2Datetime(AppointmentDate),
                ClinicID        = Convert.ToInt64(clinicId),
                EmployeeID      = Convert.ToInt64(employeeID),
                DoctorID        = Convert.ToInt64(doctorId),
                PoliID          = Convert.ToInt64(poliId),
                RequirementID   = Convert.ToInt16(necesity),
                MCUPakageID     = Convert.ToInt64(MCUPackage),
            };

            if (Session["UserLogon"] != null)
            {
                _model.Account = (AccountModel)Session["UserLogon"];
            }
            var request = new AppointmentRequest
            {
                Data = _model
            };

            response = new AppointmentValidator(_unitOfWork).Validate(request);

            return(Json(new { Status = response.Status, Message = response.Message }, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var validator = new AppointmentValidator();
            var result    = validator.Validate(this);

            return(result.Errors.Select(item => new ValidationResult(item.ErrorMessage, new[] { item.PropertyName })));
        }
예제 #4
0
 public AppointmentService(IAppointmentRepository repository, IMapper mapper, AppointmentValidator validator,
                           IUserRepository userRepository, INotificationRepository notificationRepository, IEmailService emailService)
 {
     _repository             = repository;
     _userRepository         = userRepository;
     _mapper                 = mapper;
     _validator              = validator;
     _notificationRepository = notificationRepository;
     _emailService           = emailService;
 }
예제 #5
0
        public Appointment(string id, string patientId, string diagnostic, DateTime date)
            : this()
        {
            this.id          = id;
            this.patientId   = patientId;
            this.diagnostic  = diagnostic;
            this.date        = date;
            this.isEmergency = false;

            AppointmentValidator.Validate(this);
        }
예제 #6
0
        public void GivenAppointmentWhenEndDateBeforeStartDateThenReturnsInvalid()
        {
            var model = new AppointmentViewModel()
            {
                StartDate = DateTime.Today, EndDate = DateTime.Today.AddDays(-1)
            };
            AppointmentValidator validator = new AppointmentValidator();

            FluentValidation.Results.ValidationResult results = validator.Validate(model);

            Assert.That(results.IsValid, Is.False);
            Assert.That(results.Errors.Any(x => x.PropertyName == nameof(AppointmentViewModel.EndDate)), Is.True);
        }
예제 #7
0
        public void GivenAppointmentWhenInvalidLocationLengthThenReturnsInvalid()
        {
            var model = new AppointmentViewModel()
            {
                Location = new string('-', 256)
            };
            AppointmentValidator validator = new AppointmentValidator();

            FluentValidation.Results.ValidationResult results = validator.Validate(model);

            Assert.That(results.IsValid, Is.False);
            Assert.That(results.Errors.Any(x => x.PropertyName == nameof(AppointmentViewModel.Location)), Is.True);
        }
예제 #8
0
        public void TestAppointmentValidation()
        {
            IValidator <Appointment> validator = new AppointmentValidator();

            Vet validVet = new Vet()
            {
                ID       = 1,
                Name     = "Maria Popa",
                Schedule = "08:00-16:00"
            };

            Appointment appValid = new Appointment()
            {
                ID         = 1,
                PetID      = 1,
                CustomerID = 1,
                ServiceID  = 1,
                VetID      = 1,
                Date       = System.DateTime.Parse("03/12/2021 14:50")
            };

            Appointment appInvalid = new Appointment()
            {
                ID         = 1,
                PetID      = 1,
                CustomerID = 1,
                ServiceID  = 1,
                VetID      = 1,
                Date       = System.DateTime.Parse("03/12/2021 22:00")
            };

            //validating a valid appointment
            validator.Validate(appValid, validVet);

            //trying to validate an appoinment with an invalid hour
            try
            {
                validator.Validate(appInvalid, validVet);
                Assert.Fail();
            }
            catch (ValidationException ve)
            {
                Assert.AreEqual(ve.Message, "Choose an hour that is in the schedule of the choosen vet!\n");
            }
        }
예제 #9
0
 public AppointmentsRepository(AppointmentValidator validator, string filename) : base(validator, filename, EntityToFileMapping.createAppointment)
 {
     loadFromFile();
 }