Esempio n. 1
0
        public Topic Action(string title)
        {
            if (title.IsNullOrWhiteSpace())
            {
                AddError("Titel darf nicht leer sein");
            }
            else
            {
                AddErrorIf(title.Length > 40, "Titel muss aus 40 oder weniger Zeichen bestehen");
                AddErrorIf(_dbContext.Topics.Any(Topic => Topic.Title == title), "Thema mit diesem Titel existiert bereits");
            }

            return(!HasErrors?_dbContext.Add(new Topic(title)).Entity : null);
        }
Esempio n. 2
0
        public Section Action(SectionDto dto)
        {
            var section = new Section
            {
                Title    = dto.Title,
                TopicId  = dto.TopicId,
                Position = _dbContext.Sections.Count(s => s.TopicId == dto.TopicId),
            };

            AddErrorIf(section.Title.IsNullOrWhiteSpace(), "Titel darf nicht leer sein");

            AddErrorIf(_dbContext.Sections.Any(s => s.Title == section.Title), "Abschnitt existiert bereits");

            return(!HasErrors?_dbContext.Add(section).Entity : null);
        }
Esempio n. 3
0
        public Flashcard Action(FlashcardDto dto)
        {
            AddErrorIf(dto.Question.IsNullOrWhiteSpace(), "Frage darf nicht leer sein");
            AddErrorIf(dto.Answer.IsNullOrWhiteSpace(), "Antwort darf nicht leer sein");

            var flashcard = new Flashcard
            {
                SectionId = dto.SectionId,
                Question  = dto.Question,
                Answer    = dto.Answer,
                Stage     = 1
            };

            return(!HasErrors?_dbContext.Add(flashcard).Entity : null);
        }