Пример #1
0
        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));
        }
Пример #2
0
 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");
     }
 }
Пример #3
0
        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);
        }