public async Task <ActionResult> SaveMemo(MemoDto memo) { // pull userid from JWT memo.UserLoginId = int.Parse(((ClaimsIdentity)HttpContext.User.Identity) .FindFirst(ClaimTypes.NameIdentifier).Value); var result = await _memoService.CreateAsync(memo); return(Ok(result)); }
private void Validate(MemoDto memo) { try { byte[] decoded = Convert.FromBase64String(memo.Content); using var fs = new FileStream(memo.Title + ".wav", FileMode.Create, FileAccess.Write); fs.Write(decoded, 0, decoded.Length); } catch { throw new InvalidDataException("Memo content could not be converted to .wav"); } }
public async Task <MemoDto> CreateAsync(MemoDto memo) { Validate(memo); var memoEntity = new Memo() { Id = 0, Title = memo.Title, Content = memo.Content, UserLoginId = memo.UserLoginId }; await _memoRepository.CreateAsync(memoEntity); return(memo); }