public ActionResult <Follow> GetFollowById(int id)
        {
            var follow = _service.GetFollowById(id);

            if (follow == null)
            {
                return(NotFound());
            }
            return(Ok(follow));
        }
Esempio n. 2
0
        public async Task <ActionResult <FollowModel> > DeleteFollow(long userId, long followerId)
        {
            try
            {
                var followToBeDeleted = await _followService.GetFollowById(userId, followerId);

                if (followToBeDeleted == null)
                {
                    return(NotFound());
                }

                var postModel = _mapper.Map <Follow, FollowModel>(followToBeDeleted);

                await _followService.DeleteFollow(followToBeDeleted);

                return(Ok(postModel));
            }
            catch (DBException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception e)
            {
                return(BadRequest("Internal error."));
            }
        }