예제 #1
0
        public async Task <IActionResult> Post([FromBody] UserFeedbackRequest request)
        {
            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            if (user == null)
            {
                _logger.LogInformation($"User with name: {User.Identity.Name} was not found.");
                return(StatusCode((int)HttpStatusCode.NotFound,
                                  new ErrorResponse(ErrorReasons.NotFound, "User was not found.")));
            }

            var feedback = new UserFeedbackEntry
            {
                User    = user,
                Message = request.Message,
                Rating  = request.Rating
            };

            await _repository.Insert(feedback);

            return(StatusCode((int)HttpStatusCode.NoContent));
        }
예제 #2
0
 public Task <UserFeedbackEntry> Insert(UserFeedbackEntry item)
 {
     return(Task.FromResult(Context.UserFeedbacks.Add(item).Entity));
 }