Пример #1
0
        public static DocumentQuestionDTO MapFrom(this DocumentQuestion entity)
        {
            if (entity == null)
            {
                throw new Exception(ExceptionMessages.EntityNull);
            }

            var answer = new List <string>();

            foreach (var item in entity.Answers)
            {
                answer.Add(item.FileName);
            }

            return(new DocumentQuestionDTO
            {
                Id = entity.Id,
                Description = entity.Description,
                FileNumberLimit = entity.FileNumberLimit,
                FileSize = entity.FileSize,
                IsRequired = entity.IsRequired,
                QuestionNumber = entity.QuestionNumber,
                Answers = answer
            });
        }
        private static List <DocumentQuestion> CreateObjectFromListDocumentQuestion(List <Dictionary <string, string> > documentQuestion)
        {
            List <DocumentQuestion> newList = new List <DocumentQuestion>();

            foreach (var item in documentQuestion)
            {
                if (item.Count > 0)
                {
                    var newDocumentQuestion = new DocumentQuestion();
                    newDocumentQuestion.Id              = Guid.Parse(item["Id"]);
                    newDocumentQuestion.Description     = item["Description"];
                    newDocumentQuestion.FileNumberLimit = int.Parse(item["FileNumberLimit"]);
                    newDocumentQuestion.FileSize        = int.Parse(item["FileSize"]);
                    newDocumentQuestion.FormId          = Guid.Parse(item["FormId"]);
                    newDocumentQuestion.IsRequired      = bool.Parse(item["IsRequired"]);
                    newDocumentQuestion.IsDeleted       = false;
                    newDocumentQuestion.QuestionNumber  = int.Parse(item["QuestionNumber"]);
                    newList.Add(newDocumentQuestion);
                }
            }
            return(newList);
        }