public ChecklistController(IDependencyFactory dependencyFactory)
		{
			_checklistRepository = dependencyFactory.GetInstance<ICheckListRepository>();
			_questionRepository = dependencyFactory.GetInstance<IQuestionRepository>();
			_questionResponseRepository = dependencyFactory.GetInstance<IQuestionResponseRepository>();
			_clientDetailsService = dependencyFactory.GetInstance<IClientDetailsService>();
			_getChecklistsQuery = dependencyFactory.GetInstance<IGetChecklistsQuery>();
			_checklistQuestionRepository = dependencyFactory.GetInstance<IChecklistQuestionRepository>();
			_employeeRespository = dependencyFactory.GetInstance<IEmployeeRepository>();
			_impressionRespository = dependencyFactory.GetInstance<IImpressionTypeRepository>();
			_categoryRepository = dependencyFactory.GetInstance<ICategoryRepository>();
			_timescaleRepository = dependencyFactory.GetInstance<ITimescaleRepository>();
			_userForAuditingRepository = dependencyFactory.GetInstance<IUserForAuditingRepository>();
			_siteRepository = dependencyFactory.GetInstance<ISiteRepository>();
			_checklistPdfCreator = dependencyFactory.GetInstance<IChecklistPdfCreator>();
			_clientDocumentationChecklistPdfWriter =
				dependencyFactory.GetInstance<IClientDocumentationChecklistPdfWriter>();
			_log = dependencyFactory.GetInstance<IPeninsulaLog>();
			_qaAdvisorRepository = dependencyFactory.GetInstance<IQaAdvisorRepository>();
            _industryRepository = dependencyFactory.GetInstance<IIndustryRepository>();
		    _bus = dependencyFactory.GetInstance<IBus>();
		}
Exemplo n.º 2
0
        public void Setup()
        {
            ResourceUrl = string.Format("{0}{1}/", ApiBaseUrl, "Checklists");

            _checklistRepository = ObjectFactory.GetInstance<ICheckListRepository>();
            _questionRepository = ObjectFactory.GetInstance<IQuestionRepository>();
            _questionResponseRepository = ObjectFactory.GetInstance<IQuestionResponseRepository>();
            _userForAuditingRepository = ObjectFactory.GetInstance<IUserForAuditingRepository>();

            //Creats a new checklist if does not exist.
            _checklist = _checklistRepository.GetById(ApiTestChecklistId);

            if (_checklist == null)
            {

                _checklist = new SC.Checklist()
                {
                    Id = ApiTestChecklistId,
                    ClientId = ApiTestClientId,
                    SiteId = APiTestSiteId,
                    CoveringLetterContent = ApiTestCoveringLetterContents,
                    CreatedBy = _userForAuditingRepository.GetSystemUser(),
                   CreatedOn = DateTime.Now,
                    LastModifiedBy = _userForAuditingRepository.GetSystemUser(),
                    LastModifiedOn = DateTime.Now
                };

                var questions = _questionRepository.GetAll().Take(1).ToList();

                //_checklist.UpdateQuestions(questions, new UserForAuditing());
                foreach (var question in questions)
                {
                    _checklist.Questions.Add(new ChecklistQuestion
                    {
                        Checklist = _checklist,
                        Question = question,
                        CreatedBy = _userForAuditingRepository.GetSystemUser(),
                        CreatedOn = DateTime.Now,
                        LastModifiedBy = _userForAuditingRepository.GetSystemUser(),
                        LastModifiedOn = DateTime.Now
                    });
                }

                var response = questions.First().PossibleResponses
                    .Where(r => r.ResponseType.Equals("Positive"))
                    .Select(
                        r => new SC.ChecklistAnswer()
                        {
                            SupportingEvidence = r.SupportingEvidence,
                            ActionRequired = r.ActionRequired,
                            Question = questions.First(),
                            Response = r,
                            CreatedBy = _userForAuditingRepository.GetSystemUser(),
                            CreatedOn = DateTime.Now,
                            LastModifiedBy = _userForAuditingRepository.GetSystemUser(),
                            LastModifiedOn = DateTime.Now
                        })
                    .ToList();

                _checklist.UpdateAnswers(response, _userForAuditingRepository.GetSystemUser());

                _checklistRepository.SaveOrUpdate(_checklist);
            }

            _totalNumberOfChecklistQuestions = _checklist.Questions.Count();
            _totalNumberOfChecklistAnswers = _checklist.Answers.Count();

            ObjectFactory.Container.GetInstance<IBusinessSafeSessionManager>().CloseSession();
        }
 public ChecklistTemplateController(IDependencyFactory dependencyFactory)
 {
     _templateRepository = dependencyFactory.GetInstance<IChecklistTemplateRepository>();
     _userForAuditingRepository = dependencyFactory.GetInstance<IUserForAuditingRepository>();
     _questionRepository = dependencyFactory.GetInstance<BusinessSafe.Domain.RepositoryContracts.SafeCheck.IQuestionRepository>();
 }