コード例 #1
0
ファイル: BalanceNoteService.cs プロジェクト: Shchack/Pocket
        public async Task <BalanceNoteViewModel> GetNoteByIdAsync(Guid userId, Guid id)
        {
            BalanceNote note = await _balanceNoteRepository.GetByIdAsync(userId, id);

            BalanceNoteViewModel result = new BalanceNoteViewModel(note);

            return(result);
        }
コード例 #2
0
ファイル: BalanceNoteService.cs プロジェクト: Shchack/Pocket
        public async Task <BalanceNoteViewModel> GetNoteByEffectiveDateAsync(Guid userId, DateTime effectiveDate)
        {
            BalanceNote note = await _balanceNoteRepository.GetByEffectiveDateAsync(userId, effectiveDate);

            BalanceNoteViewModel result = null;

            if (note != null)
            {
                result = new BalanceNoteViewModel(note);
            }

            return(result);
        }
コード例 #3
0
        public async Task <ActionResult <BalanceNoteViewModel> > AlterNoteAsync(DateTime effectiveDate, [FromBody] BalanceNoteUpdateModel note)
        {
            UserViewModel user = await GetCurrentUserAsync();

            if (user == null)
            {
                return(HandleUserNotFoundResult());
            }

            BalanceNoteViewModel result = await _balanceNoteService.AlterNoteAsync(user.Id, effectiveDate, note.Content);

            return(Ok(result));
        }
コード例 #4
0
        public async Task <ActionResult <BalanceNoteViewModel> > GetNoteByEffectiveDateAsync(DateTime effectiveDate)
        {
            UserViewModel user = await GetCurrentUserAsync();

            if (user == null)
            {
                return(HandleUserNotFoundResult());
            }

            BalanceNoteViewModel result = await _balanceNoteService.GetNoteByEffectiveDateAsync(user.Id, effectiveDate);

            return(Ok(result));
        }
コード例 #5
0
ファイル: BalanceNoteService.cs プロジェクト: Shchack/Pocket
        public async Task <BalanceNoteViewModel> AlterNoteAsync(Guid userId, DateTime effectiveDate, string content)
        {
            BalanceNote note = await _balanceNoteRepository.GetByEffectiveDateAsync(userId, effectiveDate);

            note = note != null
                ? await _balanceNoteRepository.UpdateAsync(userId, note.Id, content)
                : await _balanceNoteRepository.CreateAsync(userId, effectiveDate, content);

            await _unitOfWork.SaveChangesAsync();

            BalanceNoteViewModel result = new BalanceNoteViewModel(note);

            return(result);
        }