Beispiel #1
0
        private void SaveLike(HttpContext context)
        {
            int  id    = int.Parse(context.Request.Params["id"]);
            bool liked = bool.Parse(context.Request.Params["liked"]);

            if (liked)
            {
                Data.dbml.Likes l = new Data.dbml.Likes();
                l.BoardsImagesMappingID = id;
                l.UserID = Common.UserID.Value;
                GetDataContext2.Likes.InsertOnSubmit(l);
                GetDataContext2.SubmitChanges();
            }
            else
            {
                PredicateGroup group = new PredicateGroup()
                {
                    Operator = GroupOperator.And, Predicates = new List <IPredicate>()
                };
                group.Predicates.Add(Predicates.Field <Data.Standalone.Likes>(f => f.BoardsImagesMappingID, Operator.Eq, id));
                group.Predicates.Add(Predicates.Field <Data.Standalone.Likes>(f => f.UserID, Operator.Eq, Common.UserID));
                SqlConnection.Delete <Data.Standalone.Likes>(group);
            }
            UpdateUPCount();
        }
Beispiel #2
0
 private void SaveLike(HttpContext context)
 {
     int id = int.Parse(context.Request.Params["id"]);
     bool liked = bool.Parse(context.Request.Params["liked"]);
     if (liked)
     {
         Data.dbml.Likes l = new Data.dbml.Likes();
         l.BoardsImagesMappingID = id;
         l.UserID = Common.UserID.Value;
         GetDataContext2.Likes.InsertOnSubmit(l);
         GetDataContext2.SubmitChanges();
     }
     else
     {
         PredicateGroup group = new PredicateGroup() { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
         group.Predicates.Add(Predicates.Field<Data.Standalone.Likes>(f => f.BoardsImagesMappingID, Operator.Eq, id));
         group.Predicates.Add(Predicates.Field<Data.Standalone.Likes>(f => f.UserID, Operator.Eq, Common.UserID));
         SqlConnection.Delete<Data.Standalone.Likes>(group);
     }
     UpdateUPCount();
 }