Пример #1
0
        public async Task <IActionResult> CreateFeed([FromForm, Required] AddFeedRequest model)
        {
            if (!ModelState.IsValid)
            {
                _logger.LogInformation("Model state is invalid, returning bad request");
                return(BadRequest());
            }

            await _mediator.Send(new CreateFeedRequest(User, model));

            return(Redirect("~/profile"));
        }
Пример #2
0
 public IActionResult AddFeed([FromBody] AddFeedRequest request)
 {
     try
     {
         int id = repository.AddFeed(request.UserId, request.FeedCollectionId, request.Url);
         return(StatusCode((int)HttpStatusCode.Created, id));
     }
     catch (Exception e)
     {
         Log.Error(e, nameof(AddFeed));
         return(StatusCode((int)HttpStatusCode.InternalServerError, $"Add Feed unexpected error. {e.Message}"));
     }
 }
 public CreateFeedRequest(ClaimsPrincipal user, AddFeedRequest model)
 {
     User  = user;
     Model = model;
 }