public async Task <BalanceNoteViewModel> GetNoteByIdAsync(Guid userId, Guid id) { BalanceNote note = await _balanceNoteRepository.GetByIdAsync(userId, id); BalanceNoteViewModel result = new BalanceNoteViewModel(note); return(result); }
public async Task <BalanceNote> CreateAsync(Guid userId, DateTime effectiveDate, string content) { BalanceNote note = new BalanceNote(Guid.NewGuid(), effectiveDate, content, userId); EntityEntry <BalanceNote> result = await _set.AddAsync(note); return(result.Entity); }
public async Task <BalanceNote> UpdateAsync(Guid userId, Guid id, string content) { BalanceNote note = await _set.FirstOrDefaultAsync(n => n.UserId == userId && n.Id == id); note.Content = content; EntityEntry <BalanceNote> result = _set.Update(note); return(result.Entity); }
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); }
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); }
public BalanceNoteViewModel(BalanceNote note) { Id = note.Id; EffectiveDate = note.EffectiveDate; Content = note.Content; }