public ProviderController(IProviderDomain providerDomain) : base("/provider") { Get["/"] = parameters => new JsonResponse(providerDomain.GetProviders(), new DefaultJsonSerializer()); Get["/{id}"] = parameters => new JsonResponse(providerDomain.GetProvider(parameters.id), new DefaultJsonSerializer()); Post["/"] = parameters => { var providerModel = this.Bind <ProviderModel>(); var response = providerModel.ValidateModel(); if (response != null) { return(response); } var provider = new Provider { Name = providerModel.Name, CertificationLevel = providerModel.CertificationLevel }; providerDomain.CreateProvider(provider); string url = string.Format("{0}/{1}", this.Context.Request.Url, provider.Id); return(new Response() { StatusCode = HttpStatusCode.Accepted }.WithHeader("Location", url)); }; }
public void SeedData() { var provider_one = new Provider { Name = "Dr. Oz", CertificationLevel = 10 }; var provider_two = new Provider { Name = "Dr. Jekyll", CertificationLevel = 10 }; var provider_three = new Provider { Name = "Dr. Houser", CertificationLevel = 1 }; var patient_one = new Patient { Name = "Dorothy", Age = 16 }; var patient_two = new Patient { Name = "Glenda", Age = 99 }; var service_one = new Service { Name = "A New Heart", Duration = TimeSpan.FromHours(5), MinimumRequiredAge = 16, RequiredCertificationLevel = 10 }; var service_two = new Service { Name = "Consultation", Duration = TimeSpan.FromMinutes(30), MinimumRequiredAge = 18, RequiredCertificationLevel = 10 }; provider_one = _providerDomain.CreateProvider(provider_one); provider_two = _providerDomain.CreateProvider(provider_two); provider_three = _providerDomain.CreateProvider(provider_three); patient_one = _patientDomain.CreatePatient(patient_one); patient_two = _patientDomain.CreatePatient(patient_two); service_one = _serviceDomain.CreateService(service_one); service_two = _serviceDomain.CreateService(service_two); var appointment = new Appointment { Patient = patient_one, Provider = provider_one, Service = service_one, ReasonForVisit = "There's no place like home", RequestedAppointmentDate = DateTime.Parse("2000/01/01 09:00:00.000"), }; _appointmentsDomain.SetAppointment(appointment); }