示例#1
0
        public IActionResult DeletePost(PostDelete parameters)
        {
            var userID = JWTUtility.GetUserID(HttpContext);
            var role   = JWTUtility.GetRole(HttpContext);

            var post = (from posts in _context.Posts
                        where posts.Id == parameters.ID
                        select posts).Single();

            if (role != RoleType.Admin && post.Userid != userID)
            {
                return(BadRequest(new { error = "You do not have permission to delete this post" }));
            }

            var comments = from cmts in _context.Comments
                           where cmts.Postid == parameters.ID
                           select cmts;

            var likes = from lks in _context.Likes
                        where lks.Postid == parameters.ID
                        select lks;

            _context.Likes.RemoveRange(likes);
            _context.Comments.RemoveRange(comments);
            _context.Posts.Remove(post);

            _context.SaveChanges();

            return(Ok());
        }
        protected void ExecutePostChartMapEntity(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            switch (localContext.PluginExecutionContext.MessageName.ToLower())
            {
            case "create":
                // Create a new system chart that coresponds to the config record just created
                PostChartMapCreate postChartMapCreate = new PostChartMapCreate(localContext);
                postChartMapCreate.Run();
                break;

            case "update":
                // Update the fetchXml query for existing chart
                PostChartMapCreate postChartMapUpdate = new PostChartMapCreate(localContext);
                postChartMapUpdate.RunUpdate();
                break;

            case "delete":
                // Delete the system chart that was associated with the config record just deleted
                PostDelete postDelete = new PostDelete(localContext);
                postDelete.Run();
                break;

            case "publishall":
                // Create the "OOB" charts on the initial publish all.  This step deletes itself once it is done.
                PostPublishAll postPublishAll = new PostPublishAll(localContext);
                postPublishAll.Run();
                break;
            }
        }
示例#3
0
 public bool PostDelete(PostDelete post)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity = ctx.Posts.Single
                          (e => e.Id == post.Id && e.Id == postId);
         ctx.Posts.Remove(entity);
         return(ctx.SaveChanges() == 1);
     }
 }
        public PostDelete ExcluirContato(PostDelete delete)
        {
            try
            {
                _contatoRepository.removerContato(delete.PessoaId, delete.ContatoId);
            }
            catch (Exception e)
            {
                throw;
            }

            return(delete);
        }
        public IActionResult DeletePost([FromBody] PostDelete postDelete)
        {
            if (!Request.Headers.ContainsKey("Authorization"))
            {
                return(Unauthorized());
            }
            var data = _alphahomeService.DeletePost(postDelete);

            if (data.valid)
            {
                return(new JsonResult(data));
            }
            return(BadRequest(data));
        }
 public PostController(PostGetBySiteAccountName postGetBySiteAccountName,
                       PostGetBySiteAccountID postGetBySiteAccountID,
                       PostUpsert postUpsert,
                       PostDelete postDelete,
                       UserAccountGetByEmail userAccountGetByEmail,
                       IAuthorizationService authorizationService)
 {
     _postGetBySiteAccountName = postGetBySiteAccountName;
     _postGetBySiteAccountID   = postGetBySiteAccountID;
     _postUpsert            = postUpsert;
     _postDelete            = postDelete;
     _userAccountGetByEmail = userAccountGetByEmail;
     _authorizationService  = authorizationService;
 }
示例#7
0
        public Response DeletePost(PostDelete postDelete)
        {
            var procedure = "sp_del_post";

            using (var conn = new MySqlConnection(_connectionString))
            {
                try
                {
                    conn.Open();
                    var param = new DynamicParameters();
                    param.Add("mpostId", postDelete.id);
                    var data = conn.QueryFirstOrDefault <Response>(procedure, param, commandType: System.Data.CommandType.StoredProcedure);
                    return(data);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
        public PostDelete Delete(PostDelete ps)
        {
            try
            {
                var contDelete = _contatoRepository.GetContatoById(ps.PessoaId);

                foreach (var item in contDelete)
                {
                    _contatoRepository.removerContato(ps.PessoaId, item.ContatoId);
                }

                _pessoaRepository.deleteCadastro(ps.PessoaId);
            }
            catch (Exception)
            {
                throw;
            }

            return(ps);
        }
示例#9
0
 public Response DeletePost(PostDelete postDelete)
 {
     return _alphahomeRepo.DeletePost(postDelete);
 }