Example #1
0
        public async Task Delete(string id, string ownerId)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ParameterException("Id is null");
            }

            var guildOld = await GetById(id);

            if (!guildOld.Owner.Equals(ownerId))
            {
                throw new Exception("Only the owner can excluded");
            }

            try
            {
                var   filter       = new FilterDefinitionBuilder <Guild>().Eq(g => g.Id, id);
                Guild guildDeleted = await _mongoDB.Delete(filter);

                if (guildDeleted == null)
                {
                    throw new NotFoundException("Guild not found");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #2
0
        public async Task Delete(string id, string playerId)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ParameterException("Id is null");
            }
            if (string.IsNullOrEmpty(playerId))
            {
                throw new ParameterException("Player Id is null");
            }

            var messageOld = await GetById(id);

            if (!messageOld.PlayerId.Equals(playerId))
            {
                throw new Exception("Only the message owner can excluded");
            }

            try
            {
                var     filter         = new FilterDefinitionBuilder <Message>().Eq(g => g.Id, id);
                Message messageDeleted = await _mongoDB.Delete(filter);

                if (messageDeleted == null)
                {
                    throw new NotFoundException("Message not found");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #3
0
        public async Task Delete(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ParameterException("Id is null");
            }

            try
            {
                var    filter        = new FilterDefinitionBuilder <Player>().Eq(p => p.Id, id);
                Player playerDeleted = await _mongoDB.Delete(filter);

                if (playerDeleted == null)
                {
                    throw new NotFoundException("Player not found");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }