Beispiel #1
0
        public async Task <WordsList> Create(WordCardListInputModel input, UserInfo userInfo)
        {
            if (userInfo == null)
            {
                throw new NotAuthException();
            }

            if (input == null)
            {
                throw new SomeCustomException(ErrorConsts.NotFound);//TODO
            }

            var forAdd = new WordsList()
            {
                Title  = input.Title,
                UserId = userInfo.UserId,
            };

            return(await _wordsListRepository.Add(forAdd));

            //throw new System.NotImplementedException();
        }
Beispiel #2
0
        public async Task <WordsList> Update(WordCardListInputModel input, UserInfo userInfo)
        {
            if (userInfo == null)
            {
                throw new NotAuthException();
            }

            if (input?.Id == null)
            {
                throw new SomeCustomException(ErrorConsts.NotFound);
            }

            var fromDb = await _wordsListRepository.GetByIdIfAccess(input.Id.Value, userInfo.UserId);

            if (fromDb == null)
            {
                throw new SomeCustomException(ErrorConsts.NotFound);
            }

            fromDb.Title = input.Title;
            return(await _wordsListRepository.Update(fromDb));
        }