Esempio n. 1
0
 public void ActionSaveNew(SysTemplateModel model)
 {
     if (ValidSave(model))
     {
         SaveNewRedirect(model.RecordID, item.ID);
     }
 }
Esempio n. 2
0
 public void ActionApply(SysTemplateModel model)
 {
     if (ValidSave(model))
     {
         ApplyRedirect(model.RecordID, item.ID);
     }
 }
Esempio n. 3
0
 public void ActionSave(SysTemplateModel model)
 {
     if (ValidSave(model))
     {
         SaveRedirect();
     }
 }
Esempio n. 4
0
 private int GetMaxOrder(SysTemplateModel model)
 {
     return(SysTemplateService.Instance.CreateQuery()
            .Where(o => o.LangID == model.LangID)
            .Max(o => o.Order)
            .ToValue().ToInt(0) + 1);
 }
Esempio n. 5
0
        public void ActionIndex(SysTemplateModel model)
        {
            // sap xep tu dong
            string orderBy = AutoSort(model.Sort, "[Order]");

            // tao danh sach
            var dbQuery = SysTemplateService.Instance.CreateQuery()
                          .Where(o => o.LangID == model.LangID)
                          .Take(model.PageSize)
                          .OrderBy(orderBy)
                          .Skip(model.PageIndex * model.PageSize);

            ViewBag.Data      = dbQuery.ToList();
            model.TotalRecord = dbQuery.TotalRecord;
            ViewBag.Model     = model;
        }
Esempio n. 6
0
        public void ActionAdd(SysTemplateModel model)
        {
            if (model.RecordID > 0)
            {
                item = SysTemplateService.Instance.GetByID(model.RecordID);

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

                // khoi tao gia tri mac dinh khi insert
                item.LangID = model.LangID;
                item.Order  = GetMaxOrder(model);
            }

            ViewBag.Data  = item;
            ViewBag.Model = model;
        }
Esempio n. 7
0
        private bool ValidSave(SysTemplateModel model)
        {
            TryUpdateModel(item);

            ViewBag.Data  = item;
            ViewBag.Model = model;

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

            //kiem tra ten
            if (item.Name.Trim() == string.Empty)
            {
                CPViewPage.Message.ListMessage.Add("Nhập tên mẫu giao diện.");
            }

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                try
                {
                    //save
                    SysTemplateService.Instance.Save(item);

                    // save file
                    BuildFileCssJs(item);
                }
                catch (Exception ex)
                {
                    Global.Error.Write(ex);
                    CPViewPage.Message.ListMessage.Add(ex.Message);
                    return(false);
                }

                return(true);
            }

            return(false);
        }