public Task CreateQuestion(QuestionFm questionFm) { if (string.IsNullOrEmpty(questionFm.Contact)) { throw new ArgumentException($"{questionFm.Contact} is null or empty."); } if (string.IsNullOrEmpty(questionFm.Content)) { throw new ArgumentException($"{questionFm.Content} is null or empty."); } Question question = new Question() { Id = Guid.NewGuid(), Date = DateTime.UtcNow, Contact = questionFm.Contact, QuestionerName = questionFm.QuestionerName, Content = questionFm.Content }; return(_questionRepository.CreateQuestionAsync(question)); }
public Task CreateQuestion(QuestionFm questionFm) { if (string.IsNullOrEmpty(questionFm.Contact)) { throw new ArgumentException($"{questionFm.Contact} is null or empty."); } if (string.IsNullOrEmpty(questionFm.Content)) { throw new ArgumentException($"{questionFm.Content} is null or empty."); } Question question = new Question() { Id = Guid.NewGuid(), Date = DateTime.UtcNow, Contact = questionFm.Contact, QuestionerName = questionFm.QuestionerName, Content = questionFm.Content }; _questionDataSource.Add(question); return(_websiteDbContext.SaveChangesAsync()); }