Esempio n. 1
0
        public async Task <ActionResult> Delete(ReplyModel reply)
        {
            if (reply.ReplyId == null)
            {
                return(BadRequest(new { Error = "reply id is required" }));
            }
            try
            {
                var replyValue = await _replyContext.Get(reply.ReplyId);

                if (replyValue == null)
                {
                    return(NotFound());
                }
                var result = await _replyContext.Delete(replyValue);

                if (!result.Succeeded)
                {
                    return(StatusCode(500, result.Error));
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e.InnerException?.ToString() ?? e.Message);
                _mailService.SendMail(string.Empty, e.InnerException?.ToString() ?? e.Message, "error");
                return(StatusCode(500, "Internal server error"));
            }

            return(Ok(new { Success = true }));
        }
Esempio n. 2
0
        public static void DeleteReply(int id)
        {
            ReplyInfo reply = GetReply(id);
            IReply    dal   = Factory <IReply> .Create("Reply");

            dal.Delete(reply);
            Admin.UpdateForumCounts();
        }
Esempio n. 3
0
        public async Task <IActionResult> DeleteReply(int replyId, int postId)
        {
            await _replyService.Delete(replyId);

            return(RedirectToAction("Index", "Post", new { id = postId }));
        }