Exemple #1
0
        public async Task <VariantDTO> AddVariant(VariantDTO variantDTO)
        {
            Variant varianttoAdd           = _mapper.Map <Variant>(variantDTO);
            IEnumerable <Variant> variants = _variantRepository.GetAll();
            Variant existedAuthor          = variants.FirstOrDefault
                                                 (v => v.QuestionId == varianttoAdd.QuestionId && v.VariantText == varianttoAdd.VariantText);

            if (existedAuthor == null)
            {
                _variantRepository.Insert(varianttoAdd);
                _variantRepository.Save();
                return(_mapper.Map <VariantDTO>(varianttoAdd));
            }

            return(null);
        }