コード例 #1
0
ファイル: AbooksController.cs プロジェクト: yamachi4416/abook
 public async Task <ActionResult> Update(AbookUpdateModel abook)
 {
     return(await PatchResult(
                async() => await abookService.Update(abook),
                nameof(abook)
                ));
 }
コード例 #2
0
        public virtual async Task <(AbookViewModel, ServiceModelState)> Update(
            AbookUpdateModel model)
        {
            var user = context.GetCurrentUser();

            var edit = await context.Abooks
                       .WhereById(user.CurrentAbookId)
                       .SingleOrDefaultAsync();

            if (edit != null)
            {
                model.Attach(edit);
                await context.SaveChangesAsync();
            }

            return(AbookViewModel.Of(edit), null);
        }