Esempio n. 1
0
 public void ContentRootMove()
 {
     SettingUp();
     var _Move = new ContentMoveBinding
     {
         ContentPropertyID = D012.ContentPropertyID,
         ContentPropertyParentID = 0,
         Index = 1
     };
     new ContentBLL().Move(_Move, _CustomerUser.Id);
     var _List = new ContentBLL().GetRootChilds(D012.ContentPropertyID);
     Assert.IsTrue(_List.Count == 1);
     _List = new ContentBLL().GetRootParentsID(D012.ContentPropertyID);
     Assert.IsTrue(_List.Count == 1);
     _List = new ContentBLL().GetRootParentsID(D0120.ContentPropertyID);
     Assert.IsTrue(_List.Count == 2);
 }
Esempio n. 2
0
        public void Move(ContentMoveBinding Model, string UserID)
        {
            using (var _c = db)
            {
                var _CP = _c.ContentProperties.Where(m => m.ContentPropertyID == Model.ContentPropertyID).SingleOrDefault();
                Can(_CP.SiteID, UserID, _c);
                var _Item = (from p in _c.ContentProperties
                             where p.ContentPropertyID == Model.ContentPropertyID
                             select p).SingleOrDefault();
                if (Model.ContentPropertyParentID == _Item.ContentPropertyParentID)
                {
                    _c.Database.ExecuteSqlCommand(@"UPDATE ContentProperties SET Priority=Priority+1 
WHERE SiteID={0} AND ContentPropertyParentID={1} AND Priority>={2} AND Priority < {3} AND  ContentPropertyID<>{4}", _Item.SiteID, Model.ContentPropertyParentID, Model.Index, _Item.Priority, Model.ContentPropertyID);

                    _c.Database.ExecuteSqlCommand(@"UPDATE ContentProperties SET Priority=Priority-1 
WHERE SiteID={0} AND ContentPropertyParentID={1} AND Priority<= {2} AND Priority >{3} AND ContentPropertyID<>{4}", _Item.SiteID, _Item.ContentPropertyParentID, Model.Index, _Item.Priority, Model.ContentPropertyID);
                }
                else
                {
                    //SUBSTRACT OLD PARENT ID
                    _c.Database.ExecuteSqlCommand(@"UPDATE ContentProperties SET Priority=Priority-1 
WHERE SiteID={0} AND ContentPropertyParentID={1} AND Priority>= {2}  AND ContentPropertyID<>{3}", _Item.SiteID, _Item.ContentPropertyParentID, _Item.Priority, Model.ContentPropertyID);
                    //SUM NEW PARENT ID
                    _c.Database.ExecuteSqlCommand(@"UPDATE ContentProperties SET Priority=Priority+1 
WHERE SiteID={0} AND ContentPropertyParentID={1} AND Priority>={2} AND ContentPropertyID<>{3}", _Item.SiteID, Model.ContentPropertyParentID, Model.Index, Model.ContentPropertyID);

                    //UPDATE ROOTS
                    MoveRoot(Model.ContentPropertyID, Model.ContentPropertyParentID);
                }
                _Item.ContentPropertyParentID = Model.ContentPropertyParentID;
                _Item.Priority = Model.Index;
                _c.SaveChanges();

            }
        }
Esempio n. 3
0
 public IHttpActionResult Move(ContentMoveBinding model)
 {
     _ContentService.Move(model, User.Identity.GetUserId());
     return Ok();
 }