コード例 #1
0
 public async Task <ActionResult> Create(
     JournalCreateModel journal)
 {
     return(await PostResult(
                async() => await journalService.Create(journal),
                journalId => new { Id = journalId },
                nameof(journal)
                ));
 }
コード例 #2
0
ファイル: JournalService.cs プロジェクト: yamachi4416/abook
        public async Task <(string, ServiceModelState)> Create(
            JournalCreateModel model)
        {
            var journal = new Journal
            {
                Id = Guid.NewGuid().ToString()
            };

            await ValidateAccounts(journal, model);

            if (IsServiceFailure)
            {
                return(null, modelState);
            }

            model.Attach(journal);

            await context.Journals.AddAsync(journal);

            await context.SaveChangesAsync();

            return(journal.Id, null);
        }