예제 #1
0
        public ActionResult PostDel(int id)
        {
            var resultCom = _br.Query <Comment>().Where(k => k.PostID == id).Any();

            if (resultCom)
            {
                var comList = _br.Query <Comment>().Where(k => k.PostID == id).ToList();
                foreach (var item in comList)
                {
                    _db.Entry(item).State = EntityState.Deleted;
                    _db.SaveChanges();
                }
            }

            var resultLike = _brLike.Query <Like>().Where(k => k.PostID == id).Any();

            if (resultLike)
            {
                var likeList = _brLike.Query <Like>().Where(k => k.PostID == id).ToList();
                foreach (var item in likeList)
                {
                    _db.Entry(item).State = EntityState.Deleted;
                    _db.SaveChanges();
                }
            }


            var delPost = _db.Posts.Where(k => k.ID == id).FirstOrDefault();

            _db.Entry(delPost).State = EntityState.Deleted;
            _db.SaveChanges();
            return(RedirectToAction("Home", "Home"));
        }
예제 #2
0
        public ActionResult Delete(int id)
        {
            var userID = SessionSet <User> .Get("Login").ID;

            var confirm = _br.Query <RelationShip>().Where(k => k.User1ID == id && k.User2ID == userID && k.StatusID == 1).FirstOrDefault();

            _db.Entry(confirm).State = EntityState.Deleted;
            _db.SaveChanges();
            return(RedirectToAction("Home", "Home"));
        }
예제 #3
0
        public ActionResult CommentDel(int id)
        {
            var comDel = _br.Query <Comment>().Where(k => k.ID == id).FirstOrDefault();

            _db.Entry(comDel).State = EntityState.Deleted;
            _db.SaveChanges();
            return(RedirectToAction("Home", "Home"));
        }
예제 #4
0
 public void Update(T model)
 {
     _db.Entry(model).State = EntityState.Modified;
     _db.SaveChanges();
 }