コード例 #1
0
        public async Task <IActionResult> Post(string uniqueToken, [FromBody] ListReceivedViewModel listReceivedViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var user = await _userRepository.GetUserByUniqueToken(uniqueToken);

            if (user == null)
            {
                return(BadRequest("User does not exist."));
            }

            await _listRepository.AddAsync(listReceivedViewModel.Title, user.Id);

            _listRepository.CommitChanges();

            _logger.LogInfo($"New list was created.");

            return(Ok("New list was created."));
        }