Ejemplo n.º 1
0
        public ActionResult Deletetest(int id = 0)
        {
            int LoginUser = int.Parse(Request.Cookies["id"].Value);
            var q         = (from p in db.MemberTables.AsEnumerable()
                             join d in db.MemberShipTables
                             on p.MemberID equals d.MemberID
                             where d.MemberID == LoginUser && d.FriendID == id
                             select p.MemberID).First();
            int q1 = int.Parse(q.ToString());

            db.MemberShipTables.Remove(db.MemberShipTables.Where(p => p.MemberID == q1 && p.FriendID == id && p.StatusID == 1).First());
            db.MemberShipTables.Remove(db.MemberShipTables.Where(p => p.FriendID == q1 && p.MemberID == id && p.StatusID == 1).First());

            //通知
            var q2 = (from p in db.MemberTables.AsEnumerable()
                      where p.MemberID == int.Parse(Request.Cookies["id"].Value)
                      select p).First();
            NoticeTable MST8 = new NoticeTable();

            MST8.NoticeTitle = "好友邀請被拒絕";
            MST8.Date        = DateTime.Now;
            MST8.Detail      = "給" + q2.NickName + "的好友邀請被拒絕了";
            MST8.ReceiverID  = id;
            MST8.SenderID    = int.Parse(Request.Cookies["id"].Value);
            MST8.StatusID    = 19;
            db.NoticeTables.Add(MST8);
            db.SaveChanges();
            return(RedirectToAction("FriendviewNow"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 新增公告/消息
        /// </summary>
        /// <param name="UserID">用户id</param>
        /// <param name="NoticeTitle">标题</param>
        /// <param name="NoticeConten">内容</param>
        /// <returns></returns>
        public JsonResult NoticeAdd(string UserID, string NoticeTitle, string NoticeConten)
        {
            NoticeTable notice = new NoticeTable()
            {
                UserID        = Convert.ToInt32(UserID),
                NoticeTitle   = NoticeTitle,
                NoticeContent = NoticeConten
            };

            if (NoticeBll.AddNotice(notice))
            {
                return(Json(1, JsonRequestBehavior.AllowGet));
            }
            return(Json(0, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult ConfirmFriend(int id = 0)
        {
            int LoginUser = int.Parse(Request.Cookies["id"].Value);
            var q1        = (from p in db.MemberTables.AsEnumerable()
                             join d in db.MemberShipTables
                             on p.MemberID equals d.MemberID
                             where d.MemberID == LoginUser && d.FriendID == id && d.StatusID == 1
                             select d).First();

            q1.StatusID = 2;

            var q2 = (from p in db.MemberTables.AsEnumerable()
                      join d in db.MemberShipTables
                      on p.MemberID equals d.MemberID
                      where d.MemberID == id && d.FriendID == LoginUser && d.StatusID == 4
                      select d).First();

            q2.StatusID = 2;

            //配對律
            MemberShipTable MST1 = new MemberShipTable();

            MST1.MemberID = int.Parse(Request.Cookies["id"].Value);
            MST1.FriendID = id;
            MST1.StatusID = 21;
            MST1.Date     = DateTime.Now;
            db.MemberShipTables.Add(MST1);
            //通知
            var q = (from p in db.MemberTables.AsEnumerable()
                     where p.MemberID == int.Parse(Request.Cookies["id"].Value)
                     select p).First();
            NoticeTable MST8 = new NoticeTable();

            MST8.NoticeTitle = "好友邀請已確認";
            MST8.Date        = DateTime.Now;
            MST8.Detail      = q.NickName + "已成為您的好友";
            MST8.ReceiverID  = id;
            MST8.SenderID    = int.Parse(Request.Cookies["id"].Value);
            MST8.StatusID    = 19;
            db.NoticeTables.Add(MST8);

            db.SaveChanges();
            return(RedirectToAction("FriendviewNow"));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 新增公告
 /// </summary>
 /// <param name="notice">公告对象</param>
 /// <returns></returns>
 public static int AddNotice(NoticeTable notice)
 {
     using (LgShopDBEntities db = new LgShopDBEntities()) {
         try
         {
             if (notice.UserID == 0)
             {
                 return(db.Database.ExecuteSqlCommand($"insert into NoticeTable values(null,'{notice.NoticeTitle}','{notice.NoticeContent}','{DateTime.Now}',1)"));
             }
             else
             {
                 return(db.Database.ExecuteSqlCommand($"insert into NoticeTable values({notice.UserID},'{notice.NoticeTitle}','{notice.NoticeContent}','{DateTime.Now}',0)"));
             }
         }
         catch (Exception)
         {
             return(0);
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 新增公告
 /// </summary>
 /// <param name="notice">公告对象</param>
 /// <returns></returns>
 public static bool AddNotice(NoticeTable notice)
 {
     return(NoticeDal.AddNotice(notice) == 1);
 }