コード例 #1
0
        public async Task <ActionResult <UsuarioModel> > DeleteCommentPostModel(int id)
        {
            if (id <= 0)
            {
                return(NotFound());
            }
            var commentPostModel = await _commentPostServices.GetByIdAsync(id);

            if (commentPostModel == null)
            {
                return(NotFound());
            }

            _unitOfWork.BeginTransaction();
            await _commentPostServices.DeleteAsync(id);

            await _unitOfWork.CommitAsync();

            return(base.Ok());
        }
コード例 #2
0
        public async Task <IActionResult> DeleteComment(int id)
        {
            try
            {
                var userId = await GetUserIdentityAsync();

                var commentPostModel = await _commentPostServices.GetByIdAsync(id);

                if (userId == commentPostModel.IdentityUser)
                {
                    await _commentPostServices.DeleteAsync(id);
                }

                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
コード例 #3
0
        public async Task DeleteAsync(string id)
        {
            var postagens = await _postServices.GetPostsByUserAsync(id);

            var comentarios = await _commentPostRepository.GetCommentByUserAsync(id);

            var likes = await _likePostRepository.GetLikeByUserAsync(id);

            var amigos = await _amigosRepository.GetAllByUserAsync(id);

            var user = await _usuarioRepository.GetByIdAsync(id);

            foreach (var post in postagens)
            {
                await _postServices.DeleteAsync(post.Id, post.UriImage);
            }

            foreach (var comentario in comentarios)
            {
                await _commentPostRepository.DeleteAsync(comentario.Id);
            }

            foreach (var like in likes)
            {
                await _likePostRepository.DeleteAsync(like.Id);
            }

            foreach (var amigo in amigos)
            {
                await _amigosRepository.DeleteAsync(amigo.Id);
            }

            await _blobServices.DeleteBlobAsync(user.FotoPerfil);

            await _usuarioRepository.DeleteAsync(id);
        }