private static AnswerViewModel Map(ChecklistAnswer answer, Question question)
        {
            if (answer != null)
            {
                AnswerViewModel model = new AnswerViewModel()
                {
                    SupportingEvidence = answer.SupportingEvidence,
                    ActionRequired = answer.ActionRequired,
                    SelectedResponseId = answer.Response != null ? (Guid?) answer.Response.Id : null,
                    QuestionId = answer.Question.Id,
                    GuidanceNotes = answer.GuidanceNotes,
                    Timescale =
                        answer.Timescale == null
                            ? null
                            : new TimescaleViewModel() {Id = answer.Timescale.Id, Name = answer.Timescale.Name},
                    AssignedTo = null,
                    QaComments = answer.QaComments,
                    QaSignedOffBy = answer.QaSignedOffBy,
                    ReportLetterStatement = answer.Response != null ? answer.Response.ReportLetterStatement : ""
                };

                if (answer.AssignedTo != null)
                {
                    model.AssignedTo = new AssignedToViewModel()
                    {
                        Id = (Guid?) answer.AssignedTo.Id,
                        NonEmployeeName = answer.AssignedTo.FullName
                    };
                }
                else if (!string.IsNullOrEmpty(answer.EmployeeNotListed))
                {
                    model.AssignedTo = new AssignedToViewModel()
                    {
                        Id = (Guid?) Guid.Empty,
                        NonEmployeeName = answer.EmployeeNotListed
                    };
                }



                return model;
            }
            else
            {
                return new AnswerViewModel()
                {
                    QuestionId = question.Id
                };
            }
        }
Пример #2
0
        private static AnswerViewModel Map(ChecklistAnswer answer, Question question)
        {
            if (answer != null)
            {
                AnswerViewModel model = new AnswerViewModel()
                {
                    SupportingEvidence = answer.SupportingEvidence,
                    ActionRequired = answer.ActionRequired,
                    SelectedResponseId = answer.Response != null ? (Guid?) answer.Response.Id : null,
                    QuestionId = answer.Question.Id,
                    GuidanceNotes = answer.GuidanceNotes,
                    Timescale =
                        answer.Timescale == null
                            ? null
                            : new TimescaleViewModel() {Id = answer.Timescale.Id, Name = answer.Timescale.Name},
                    AssignedTo = null,
                    QaComments = answer.QaComments,
                    QaSignedOffBy = answer.QaSignedOffBy,
                    QaSignedOffDate = answer.QaSignedOffDate,
                    ReportLetterStatement = answer.Response != null ? answer.Response.ReportLetterStatement : "",
                    QaCommentsResolved = answer.QaCommentsResolved,
                    AreaOfNonCompliance = answer.AreaOfNonCompliance,
                    SupportingDocumentationStatus = answer.SupportingDocumentationStatus,
                    SupportingDocumentationDate = answer.SupportingDocumentationDate.ToUniversalTime()

                };

                if (answer.AssignedTo != null)
                {
                    model.AssignedTo = new AssignedToViewModel()
                    {
                        Id = (Guid?) answer.AssignedTo.Id,
                        ForeName = answer.AssignedTo.Forename,
                        Surname = answer.AssignedTo.Surname,
                        FullName = answer.AssignedTo.FullName,
                        EmailAddress = answer.AssignedTo.HasEmail ? answer.AssignedTo.GetEmail() : string.Empty
                    };
                }
                else if (!string.IsNullOrEmpty(answer.EmployeeNotListed))
                {
                    model.AssignedTo = new AssignedToViewModel()
                    {
                        Id = (Guid?) Guid.Empty,
                        NonEmployeeName = answer.EmployeeNotListed
                    };
                }

                return model;
            }
            else
            {
                return new AnswerViewModel()
                {
                    QuestionId = question.Id
                };
            }
        }