Blog.Web.Api.Controllers.CommunityController.Join C# (CSharp) Method

Join() private method

private Join ( [ user, int communityId ) : IHttpActionResult
user [
communityId int
return IHttpActionResult
        public IHttpActionResult Join([FromBody]User user, int communityId)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return BadRequest(ModelState);
                }

                var community = _communityResource.Get(communityId);
                if (community == null) throw new Exception("Cannot update community at the moment.");

                community.Members.Add(user);

                return Ok(_communityResource.Update(community));
            }
            catch (Exception ex)
            {
                _errorSignaler.SignalFromCurrentContext(ex);
                var errorResult = new Community
                {
                    Error = new Error
                    {
                        Id = (int)Common.Utils.Constants.Error.InternalError,
                        Message = ex.Message
                    }
                };
                return Ok(errorResult);
            }
        }