Ejemplo n.º 1
0
        public int Save(PageBinding Model, bool CreateContent = true)
        {
            using (var _c = db)
            {
                var _IQParent = _c.Pages.Where(m => m.SiteID == Model.SiteID && m.PageParentID == Model.PageParentID);
                var _Model = new Page();
                _Model.PageParentID = Model.PageParentID;
                _Model.Alias = Model.Alias;
                _Model.SiteID = Model.SiteID;
                _Model.Priority = _IQParent.Any() ? _IQParent.Select(m => m.Priority).Max() + 1 : 0;
                _Model.InMenu = Model.InMenu;
                _c.Pages.Add(_Model);
                _c.SaveChanges();

                if (CreateContent)
                {
                    if (_Model.PageParentID == 0)
                    {
                        //CRETING CONTENT LIST
                        var _Content = new ContentBinding
                        {
                            ContentPropertyAlias = Model.Alias,
                            //ContentPropertyParentID = (_c.Pages.Where(m => m.PageID == Model.PageParentID).Any()
                            //? _c.ContentPropertyCultures.Where(m => m.ContentProperty.SiteID == Model.SiteID && m.ContentProperty.ContentPropertyAlias.Equals(_c.Pages.Where(m2 => m2.PageID == Model.PageParentID).FirstOrDefault().Alias)).FirstOrDefault().ContentProperty.ContentPropertyID
                            //: 0),
                            ContentPropertyParentID = 0,
                            SiteID = Model.SiteID,
                            Lock = false,
                            ContentPropertyType = ContentPropertyType.LIST,
                        };
                        new ContentBLL().Save(_Content);
                    }
                }
                return _Model.PageID;
            }
        }
Ejemplo n.º 2
0
 public IHttpActionResult PostSave(PageBinding Model)
 {
     return Ok(_PageService.Save(Model, User.Identity.GetUserId()));
 }
Ejemplo n.º 3
0
 public int Save(PageBinding Model, string UserID)
 {
     using (var _c = db)
     {
         Can(Model.SiteID, UserID, _c);
         return Save(Model);
     }
 }