Пример #1
0
 public void ActionApply(ModAdvModel model)
 {
     if (ValidSave(model))
     {
         ApplyRedirect(model.RecordID, entity.ID);
     }
 }
Пример #2
0
 public void ActionSaveNew(ModAdvModel model)
 {
     if (ValidSave(model))
     {
         SaveNewRedirect(model.RecordID, entity.ID);
     }
 }
Пример #3
0
 public void ActionSave(ModAdvModel model)
 {
     if (ValidSave(model))
     {
         SaveRedirect();
     }
 }
Пример #4
0
        public void ActionIndex(ModAdvModel model)
        {
            // sap xep tu dong
            string orderBy = AutoSort(model.Sort, "[Order]");

            // tao danh sach
            var dbQuery = ModAdvService.Instance.CreateQuery()
                                .WhereIn(o => o.MenuID, WebMenuService.Instance.GetChildIDForCP("Adv", model.MenuID, model.LangID))
                                .Take(model.PageSize)
                                .OrderBy(orderBy)
                                .Skip(model.PageIndex * model.PageSize);

            ViewBag.Data = dbQuery.ToList();
            model.TotalRecord = dbQuery.TotalRecord;
            ViewBag.Model = model;
        }
Пример #5
0
        public void ActionIndex(ModAdvModel model)
        {
            // sap xep tu dong
            string orderBy = AutoSort(model.Sort, "[Order]");

            // tao danh sach
            var dbQuery = ModAdvService.Instance.CreateQuery()
                          .WhereIn(o => o.MenuID, WebMenuService.Instance.GetChildIDForCP("Adv", model.MenuID, model.LangID))
                          .Take(model.PageSize)
                          .OrderBy(orderBy)
                          .Skip(model.PageIndex * model.PageSize);

            ViewBag.Data      = dbQuery.ToList();
            model.TotalRecord = dbQuery.TotalRecord;
            ViewBag.Model     = model;
        }
Пример #6
0
        private bool ValidSave(ModAdvModel model)
        {
            TryUpdateModel(entity);

            //chong hack
            entity.ID = model.RecordID;

            ViewBag.Data  = entity;
            ViewBag.Model = model;

            CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error;

            //kiem tra quyen han
            if ((model.RecordID < 1 && !CPViewPage.UserPermissions.Add) || (model.RecordID > 0 && !CPViewPage.UserPermissions.Edit))
            {
                CPViewPage.Message.ListMessage.Add("Quyền hạn chế.");
            }

            //kiem tra chuyen muc
            if (entity.MenuID < 1)
            {
                CPViewPage.Message.ListMessage.Add("Chọn chuyên mục.");
            }

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                try
                {
                    //save
                    ModAdvService.Instance.Save(entity);
                }
                catch (Exception ex)
                {
                    Global.Error.Write(ex);
                    CPViewPage.Message.ListMessage.Add(ex.Message);
                    return(false);
                }

                return(true);
            }

            return(false);
        }
Пример #7
0
        public void ActionAdd(ModAdvModel model)
        {
            if (model.RecordID > 0)
            {
                entity = ModAdvService.Instance.GetByID(model.RecordID);

                // khoi tao gia tri mac dinh khi update
            }
            else
            {
                entity = new ModAdvEntity();

                // khoi tao gia tri mac dinh khi insert
                entity.MenuID   = model.MenuID;
                entity.Activity = CPViewPage.UserPermissions.Approve;
                entity.Order    = GetMaxOrder(model);
            }

            ViewBag.Data  = entity;
            ViewBag.Model = model;
        }
Пример #8
0
        public void ActionAdd(ModAdvModel model)
        {
            if (model.RecordID > 0)
            {
                entity = ModAdvService.Instance.GetByID(model.RecordID);

                // khoi tao gia tri mac dinh khi update
            }
            else
            {
                entity = new ModAdvEntity();

                // khoi tao gia tri mac dinh khi insert
                entity.MenuID = model.MenuID;
                entity.Activity = CPViewPage.UserPermissions.Approve;
                entity.Order = GetMaxOrder(model);
            }

            ViewBag.Data = entity;
            ViewBag.Model = model;
        }
Пример #9
0
 private int GetMaxOrder(ModAdvModel model)
 {
     return(ModAdvService.Instance.CreateQuery()
            .Max(o => o.Order)
            .ToValue().ToInt(0) + 1);
 }
Пример #10
0
        private bool ValidSave(ModAdvModel model)
        {
            TryUpdateModel(entity);

            //chong hack
            entity.ID = model.RecordID;

            ViewBag.Data = entity;
            ViewBag.Model = model;

            CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error;

            //kiem tra quyen han
            if ((model.RecordID < 1 && !CPViewPage.UserPermissions.Add) || (model.RecordID > 0 && !CPViewPage.UserPermissions.Edit))
                CPViewPage.Message.ListMessage.Add("Quyền hạn chế.");

            //kiem tra chuyen muc
            if (entity.MenuID < 1)
                CPViewPage.Message.ListMessage.Add("Chọn chuyên mục.");

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                try
                {
                    //save
                    ModAdvService.Instance.Save(entity);
                }
                catch (Exception ex)
                {
                    Global.Error.Write(ex);
                    CPViewPage.Message.ListMessage.Add(ex.Message);
                    return false;
                }

                return true;
            }

            return false;
        }
Пример #11
0
 private int GetMaxOrder(ModAdvModel model)
 {
     return ModAdvService.Instance.CreateQuery()
             .Max(o => o.Order)
             .ToValue().ToInt(0) + 1;
 }
Пример #12
0
 public void ActionSaveNew(ModAdvModel model)
 {
     if (ValidSave(model))
         SaveNewRedirect(model.RecordID, entity.ID);
 }
Пример #13
0
 public void ActionSave(ModAdvModel model)
 {
     if (ValidSave(model))
         SaveRedirect();
 }
Пример #14
0
 public void ActionApply(ModAdvModel model)
 {
     if (ValidSave(model))
         ApplyRedirect(model.RecordID, entity.ID);
 }