public ActionResult <ReactionReadDto> Create([FromBody] ReactionCreateDto request) { if (_userRepository.Get(request.UserId) == null) { return(StatusCode(StatusCodes.Status400BadRequest, "User doesn't exist.")); } if (_postRepository.Get(request.PostId) == null) { return(StatusCode(StatusCodes.Status400BadRequest, "Post doesn't exist.")); } if (_reactionTypeRepository.Get(request.ReactionTypeId) == null) { return(StatusCode(StatusCodes.Status400BadRequest, "Reaction type doesn't exist.")); } Reaction newEntity = _mapper.Map <Reaction>(request); newEntity.DateTime = DateTime.UtcNow; Reaction result = _reactionRepository.Create(newEntity); return(StatusCode(StatusCodes.Status201Created, _mapper.Map <ReactionReadDto>(result))); }
public ActionResult <IEnumerable <ReactionTypeReadDto> > Get() { List <ReactionType> result = _repository.Get().ToList(); return(StatusCode(StatusCodes.Status200OK, _mapper.Map <IEnumerable <ReactionTypeReadDto> >(result))); }