public CheckListTemplateEditModel GetbyId(long id)
        {
            var groupQuestions = _checkListTemplateRepository.GetAllGroupQuestions();
            var questions      = _checkListQuestionRepository.GetAllQuestions();

            if (id <= 0)
            {
                return new CheckListTemplateEditModel()
                       {
                           Questions = CreateChecklistGroupQuestionList(groupQuestions, questions, null)
                       }
            }
            ;

            var template = _checkListTemplateRepository.GetById(id);
            var selectedGroupQuestionIds = _checkListTemplateRepository.GetGroupQuestionIdsByTemplateId(id);

            return(new CheckListTemplateEditModel
            {
                //HealthPlanId = template.HealthPlanId.HasValue ? template.HealthPlanId.Value : 0,
                Id = template.Id,
                IsActive = template.IsActive,
                IsPublished = template.IsPublished,
                Name = template.Name,
                Questions = CreateChecklistGroupQuestionList(groupQuestions, questions, selectedGroupQuestionIds),
                Type = template.Type
            });
        }
示例#2
0
        public bool CheckifNameisUnique(CheckListTemplateEditModel model, string templateName)
        {
            if (model.Id > 0)
            {
                var inDb = _templateRepository.GetById(model.Id);
                if (inDb.Name == templateName)
                {
                    return(true);
                }
            }

            if (string.IsNullOrEmpty(templateName))
            {
                return(false);
            }

            var template = _templateRepository.GetByName(templateName.Trim());

            if (template != null)
            {
                return(false);
            }

            return(true);
        }
        public CheckListFormEditModel GetCustomerCheckListEdtiModel(Customer customer, CorporateAccount account, EventCustomer eventCustomer)
        {
            var preApporvedTestNames = _eventCustomerPreApprovedTestRepository.GetPreApprovedTestNameByEventCustomerId(eventCustomer.Id);
            var result = _eventCustomerResultRepository.GetById(eventCustomer.Id);

            var template = _checkListTemplateRepository.GetTemplateByEventId(eventCustomer.EventId);

            if (template == null && account.CheckListTemplateId.HasValue)
            {
                template = _checkListTemplateRepository.GetById(account.CheckListTemplateId.Value);
            }
            else if (template == null)
            {
                template = _checkListTemplateRepository.GetDefaultTemplate();
            }

            var templateGroup           = _checkListGroupRepository.GetAllGroups();
            var checkListQuestion       = _checkListQuestionRepository.GetAllQuestionsForTemplateId(template.Id);
            var checklistGroupQuestions = _checkListTemplateRepository.GetAllGroupQuestionsForTemplateId(template.Id);

            var version    = _checkListAnswerRepository.GetLatestVersion(eventCustomer.Id);
            var answerList = new List <CheckListAnswer>();

            if (version > 0)
            {
                answerList = _checkListAnswerRepository.GetAllAnswerByEventCustomerId(eventCustomer.Id, version).ToList();
            }

            return(new CheckListFormEditModel
            {
                CustomerId = customer.CustomerId,
                PreApporvedTestNames = preApporvedTestNames,
                EventId = eventCustomer.EventId,
                Name = customer.Name,
                DoB = customer.DateOfBirth,
                //HealthPlanName = (template.HealthPlanId.HasValue && account != null) ? account.Name : string.Empty,
                EventCustomerId = eventCustomer.Id,
                CheckListQuestion = _checkListQuestionAnswerEditModelFactory.CheckListQuestionAnswerEditModel(checkListQuestion, answerList, templateGroup, checklistGroupQuestions),
                IsEditable = result == null || result.ResultState < (long)TestResultStateNumber.PreAudit,
                Gender = customer.Gender
            });
        }