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); }
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)); }
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 }))); }
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; }
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); }
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); }
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); }
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"); } }
public AppointmentsRepository(AppointmentValidator validator, string filename) : base(validator, filename, EntityToFileMapping.createAppointment) { loadFromFile(); }