Inheritance: BaseObject
Exemplo n.º 1
0
 public Community Update(Community community)
 {
     using (var svc = new ServiceProxyHelper<ICommunityService>("CommunityService"))
     {
         return svc.Proxy.Update(community);
     }
 }
Exemplo n.º 2
0
 public Community Update(Community community)
 {
     return _communityLogic.Update(community);
 }
Exemplo n.º 3
0
 public Community Add(Community community)
 {
     return _communityLogic.Add(community);
 }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        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();
 }