Ejemplo n.º 1
0
        public async Task Delete(DeletePostInput input)
        {
            // Determine user is the author of the post or not
            (var res, var post) = await IsOwner(AbpSession.UserId, input.Id);

            if (!res)
            {
                return;
            }

            ObjectMapper.Map(input, post);
            await _postManager.DeleteAsync(post);
        }
        public async Task Delete(DeletePostInput input)
        {
            var entity = await _manager.GetById(input.Id);

            if (entity == null)
            {
                throw new UserFriendlyException($"Post {input.Id} not found");
            }

            if (entity.UserId != AbpSession.UserId)
            {
                throw new Exception("Access denied");
            }

            await _manager.Delete(input.Id);
        }