public Community Update(Community community) { using (var svc = new ServiceProxyHelper<ICommunityService>("CommunityService")) { return svc.Proxy.Update(community); } }
public Community Update(Community community) { return _communityLogic.Update(community); }
public Community Add(Community community) { return _communityLogic.Add(community); }
public Community Update(Community community) { try { var checkCommunity = IsCommunityNameInUse(community.Name, community.Id); if (checkCommunity) { return new Community().GenerateError<Community>((int)Constants.Error.ValidationError, string.Format("Community name {0} is already in use.", community.Name)); } return CommunityMapper.ToDto(_communityRepository.Edit(CommunityMapper.ToEntity(community))); } catch (Exception ex) { throw new BlogException(ex.Message, ex.InnerException); } }
public Community Add(Community community) { try { var checkCommunity = IsCommunityNameInUse(community.Name); if (checkCommunity) { return new Community().GenerateError<Community>((int)Constants.Error.ValidationError, string.Format("Community name {0} is already in use.", community.Name)); } community.Members = new List<User>(); community.Members.Add(community.Leader); return CommunityMapper.ToDto(_communityRepository.Add(CommunityMapper.ToEntity(community))); } catch (Exception ex) { throw new BlogException(ex.Message, ex.InnerException); } }
public IHttpActionResult Leave([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."); var tempMembers = new List<User>(); foreach (var member in community.Members) { if (user.Id != member.Id) { tempMembers.Add(member); } } community.Members = tempMembers; 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); } }
public IHttpActionResult Put([FromBody]Community community) { try { if (!ModelState.IsValid) { return BadRequest(ModelState); } var tCommunity = _communityResource.Get(community.Id); var isAllowed = User.Identity.GetUserName() == tCommunity.Leader.UserName; if (isAllowed) return Ok(_communityResource.Update(community)); var notAllowedResult = new Community { Error = new Error { Id = (int)Common.Utils.Constants.Error.RequestNotAllowed, Message = "Request not allowed. You cannot edit someone else's community." } }; return Ok(notAllowedResult); } 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); } }
public IHttpActionResult Post([FromBody]Community community) { try { if (!ModelState.IsValid) { return BadRequest(ModelState); } return Ok(_communityResource.Add(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); } }
public Community Update(Community community, string authenticationToken) { throw new System.NotImplementedException(); }