Exemple #1
0
        public JsonResult GetCommunityByURL([FromQuery] string url)
        {
            JSONObjectResult result = new JSONObjectResult
            {
                Status = System.Net.HttpStatusCode.OK
            };

            try
            {
                if (string.IsNullOrEmpty(url))
                {
                    throw new Exception("An error ocurred trying to get a community by url");
                }

                var community = _mapper.Map <CommunityViewModel>(_communityService.GetCommunityByURL(url));
                result.Data = community;
            }
            catch (Exception e)
            {
                result.Status = System.Net.HttpStatusCode.BadRequest;
                result.Errors.Add(e.Message);
            }

            return(new JsonResult(result));
        }