public void JuniorTest() { var customer = new Customer { //Id = 99, AccountType = _accountTypeRepository.GetAccountTypeByName(AccountType.CurrentAccount.Value), CustomerName = "Junior1" }; _customerRepository.Add(customer); var survey = _surveyRepository.GetAll().FirstOrDefault(s => s.Title == Survey.FirstSurvey.Item2); var custSurv = new CustomerSurvey { CustomerId = customer.Id, SurveyId = survey.Id, Date = DateTime.Now }; _customerSurveyRepository.Add(custSurv); var ageQuestion = _questionRepository.GetAll().FirstOrDefault(q => q.QuestionText == Question.Age.Value); //Age? var selectedAge = _possibleAnswersRepository.GetAll().FirstOrDefault(pa => pa.Text == PossibleAnswers.Age_0_17.Value); //"0-17" var answerAge = new Answer { CustomerId = customer.Id, SurveyId = survey.Id, QuestionId = ageQuestion.Id, SelectedAnswerId = selectedAge.Id }; _answerRepository.Add(answerAge); var studQuestion = _questionRepository.GetAll().FirstOrDefault(q => q.QuestionText == Question.Student.Value);; //Is Student? var selectedStud = _possibleAnswersRepository.GetAll().FirstOrDefault(pa => pa.Text == PossibleAnswers.No.Value); //"no" var answerStud = new Answer { CustomerId = customer.Id, SurveyId = survey.Id, QuestionId = studQuestion.Id, SelectedAnswerId = selectedStud.Id }; _answerRepository.Add(answerStud); var incomeQuestion = _questionRepository.GetAll().FirstOrDefault(q => q.QuestionText == Question.Income.Value); //Income? var selectedIncome = _possibleAnswersRepository.GetAll().FirstOrDefault(pa => pa.Text == PossibleAnswers.Income_0.Value); //"0" var answerIncome = new Answer { CustomerId = customer.Id, SurveyId = survey.Id, QuestionId = incomeQuestion.Id, SelectedAnswerId = selectedIncome.Id }; _answerRepository.Add(answerIncome); var bundleRecomemndation = new BundleRecomendationService(_context); Bundle recomendeBundle = bundleRecomemndation.Recommend(customer, survey); _output.WriteLine($"Recomended Bundle: {recomendeBundle?.BundleName} Value: {recomendeBundle?.Value}"); Assert.Equal(Bundle.JuniorSaver.Value, recomendeBundle?.BundleName); _output.WriteLine($"\tIncluded Product: {recomendeBundle?.ProductIncluded?.FirstOrDefault().Product.ProductName}"); Assert.Equal(Product.JuniorSaverAccount.Value, recomendeBundle?.ProductIncluded?.FirstOrDefault().Product.ProductName); }
public ActionResult Index() { //get all surveys IList <Survey> surveys = _surveyRepository.GetAll(); //parse to JSON return(Ok(surveys)); }
public List <Appointment> GetSurveyableAppointments(string id) { List <Survey> surveys = _surveyRepository.GetAll().ToList(); List <Appointment> appointments = GetAllForPatient(id); List <Appointment> surveyableAppointments = new List <Appointment>(); surveyableAppointments = appointments.Where(p => !surveys.Any(l => p.Id == l.AppointmentId) && p.Finished && !p.CanceledByPatient).ToList(); return(surveyableAppointments); }
public string GetResults(string data) { var surveys = _surveyRepository.GetAll(data); int caseNumber = 1; var result = new StringBuilder(); foreach (var survey in surveys) { var students = GetNames(survey).OrderBy(x => x.Name); var text = GetStudentText(students); result.AppendLine($"Case #{caseNumber}: {text}"); caseNumber++; } return(result.ToString()); }
public ActionResult <IEnumerable <Survey> > Get() { return(repository.GetAll().ToList()); }
public IEnumerable <Model.Survey> GetSurveys() { return(_surveyRepository.GetAll <Model.Survey>().OrderBy(s => s.SurveyName).ToList()); }
public void Junior_CanAdd_JuniorAccount_Test() { var customer = new Customer { AccountType = _accountTypeRepository.GetAccountTypeByName(AccountType.CurrentAccount.Value), CustomerName = "Junior2" }; _customerRepository.Add(customer); var survey = _surveyRepository.GetAll().FirstOrDefault(s => s.Title == Survey.FirstSurvey.Item2); var custSurv = new CustomerSurvey { CustomerId = customer.Id, SurveyId = survey.Id, Date = DateTime.Now }; _customerSurveyRepository.Add(custSurv); var ageQuestion = _questionRepository.GetAll().FirstOrDefault(q => q.QuestionText == Question.Age.Value); //Age? var selectedAge = _possibleAnswersRepository.GetAll().FirstOrDefault(pa => pa.Text == PossibleAnswers.Age_0_17.Value); //"0-17" var answerAge = new Answer { CustomerId = customer.Id, SurveyId = survey.Id, QuestionId = ageQuestion.Id, SelectedAnswerId = selectedAge.Id }; _answerRepository.Add(answerAge); var studQuestion = _questionRepository.GetAll().FirstOrDefault(q => q.QuestionText == Question.Student.Value);; //Is Student? var selectedStud = _possibleAnswersRepository.GetAll().FirstOrDefault(pa => pa.Text == PossibleAnswers.No.Value); //"no" var answerStud = new Answer { CustomerId = customer.Id, SurveyId = survey.Id, QuestionId = studQuestion.Id, SelectedAnswerId = selectedStud.Id }; _answerRepository.Add(answerStud); var incomeQuestion = _questionRepository.GetAll().FirstOrDefault(q => q.QuestionText == Question.Income.Value); //Income? var selectedIncome = _possibleAnswersRepository.GetAll().FirstOrDefault(pa => pa.Text == PossibleAnswers.Income_0.Value); //"0" var answerIncome = new Answer { CustomerId = customer.Id, SurveyId = survey.Id, QuestionId = incomeQuestion.Id, SelectedAnswerId = selectedIncome.Id }; _answerRepository.Add(answerIncome); var bundleRecomemndation = new BundleRecomendationService(_context); Bundle recomendeBundle = bundleRecomemndation.Recommend(customer, survey); var product = _productRepository.GetByName(Product.JuniorSaverAccount.Value); var prodSelection = new ProducSelectionService(_context); string msg; var res = prodSelection.IsCanAddProduct(product, customer, survey, out msg); _output.WriteLine($"Recomended Bundle: {recomendeBundle?.BundleName} \tValue: {recomendeBundle?.Value}"); foreach (var productBundle in recomendeBundle?.ProductIncluded) { _output.WriteLine($"\tIncluded Product: {productBundle.Product.ProductName}"); } _output.WriteLine($"\tres: [{res}], Msg: [{msg}]"); Assert.True(res); //Assert.Equal("Stud not hits", msg); }
public ActionResult <List <SurveyDTO> > GetSurveys() { var surveys = _surveyRepository.GetAll(); return(_mapper.Map <List <SurveyDTO> >(surveys)); }
public IEnumerable <Survey> GetAll() { return(_sr.GetAll()); }
public List <Survey> GetAllSurveys() { return(surveyRepository.GetAll()); }