Exemple #1
0
        public ActionResult Delete(int id)
        {
            ApplicationDbContext _context = new ApplicationDbContext();

            BlogHandler blogHandler = new BlogHandler();
            //  var blog = _context.Blogs.Include(x=>x.BlogComments).Where(s => s.Id == id).SingleOrDefault();

            // blog.BlogComments.RemoveAll(x => x.BlogID == blog.Id);

            //_context.Blogs.Remove(blog);


            //foreach (var child in blog.BlogComments)
            //{
            //    _context.Entry(child).State = System.Data.Entity.EntityState.Deleted;
            //}

            Blog blog = blogHandler.GetBlogById(id);

            blog.BlogComments.RemoveAll(x => x.BlogID == id);

            _context.Entry(blog).State = System.Data.Entity.EntityState.Deleted;

            //  _context.Blogs.Remove(blog);
            _context.SaveChanges();

            return(RedirectToAction("BlogTable"));
        }
Exemple #2
0
        public async Task UnSubscribe(string name)
        {
            await Context.Message.DeleteAsync();

            var embed = BlogHandler.UnSubscribeToBlog(Context.User.Id, name);

            await Context.Channel.SendMessageAsync("", false, embed);
        }
Exemple #3
0
        private Task OnReactionAdded(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel channel, SocketReaction reaction)
        {
            if (!reaction.User.Value.IsBot)
            {
                var msgList = Global.MessagesIdToTrack ?? new Dictionary <ulong, string>();
                if (msgList.ContainsKey(reaction.MessageId))
                {
                    if (reaction.Emote.Name == "➕")
                    {
                        var item  = msgList.FirstOrDefault(k => k.Key == reaction.MessageId);
                        var embed = BlogHandler.SubscribeToBlog(reaction.User.Value.Id, item.Value);
                    }
                }
            }

            return(Task.CompletedTask);
        }
Exemple #4
0
        public ActionResult BlogTable(string search, int?pageNo)
        {
            AllBlogViewModel model   = new AllBlogViewModel();
            BlogHandler      handler = new BlogHandler();

            model.SearchItem = search;
            pageNo           = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1;

            var totalRecord = handler.GetBlogsCount(search);

            model.BlogsList = handler.GetAllBlogs(search, pageNo.Value);

            if (model.BlogsList != null)
            {
                model.Pager = new Pager(totalRecord, pageNo, 6);
                return(PartialView("_BlogTable", model));
            }
            return(PartialView("_BlogTable", model));
        }
 public Blogs(JsonDataStorage jsonDataStorage, BlogHandler blogHandler)
 {
     this.jsonDataStorage = jsonDataStorage;
     this.blogHandler     = blogHandler;
 }
Exemple #6
0
        public BlogHandlerTest()
        {
            blogService = Strict <IBlogService>();

            handler = new BlogHandler(blogService.Object);
        }