Пример #1
0
        public IActionResult GetById([FromForm(Name = "id")] int id)
        {
            var result = _likeService.GetById(id);

            if (result.Succcess)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
        public IActionResult GetById(int id)
        {
            try
            {
                var like = _likeService.GetById(id);

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

                var model = _mapper.Map <LikeViewModel>(like);

                _log.LogInformation("this Like has been got successfully ", $"the Like with id {model.Id} has been got successfully.");

                return(Ok(model));
            }
            catch (Exception ex)
            {
                _log.LogError("Error occured while getting Like", "", $"{ex.Message}");
                return(new BadRequestObjectResult(id));
            }
        }