Exemplo n.º 1
0
        private bool ValidSave(SysTemplateModel model)
        {
            TryUpdateModel(entity);

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

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

            //kiem tra ten
            if (entity.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(entity);
                }
                catch (Exception ex)
                {
                    Global.Error.Write(ex);
                    CPViewPage.Message.ListMessage.Add(ex.Message);
                    return(false);
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
 public void ActionApply(SysTemplateModel model)
 {
     if (ValidSave(model))
     {
         ApplyRedirect(model.RecordID, entity.ID);
     }
 }
Exemplo n.º 3
0
 public void ActionSaveNew(SysTemplateModel model)
 {
     if (ValidSave(model))
     {
         SaveNewRedirect(model.RecordID, entity.ID);
     }
 }
Exemplo 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);
 }
Exemplo n.º 5
0
 public void ActionSave(SysTemplateModel model)
 {
     if (ValidSave(model))
     {
         SaveRedirect();
     }
 }
Exemplo n.º 6
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;
        }
        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;
        }
Exemplo n.º 8
0
        public void ActionAdd(SysTemplateModel model)
        {
            if (model.RecordID > 0)
            {
                entity = SysTemplateService.Instance.GetByID(model.RecordID);

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

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

            ViewBag.Data  = entity;
            ViewBag.Model = model;
        }
        public void ActionAdd(SysTemplateModel model)
        {
            if (model.RecordID > 0)
            {
                entity = SysTemplateService.Instance.GetByID(model.RecordID);

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

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

            ViewBag.Data = entity;
            ViewBag.Model = model;
        }
Exemplo n.º 10
0
        private bool ValidSave(SysTemplateModel model)
        {
            TryUpdateModel(entity);

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

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

            //kiem tra ten
            if (entity.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(entity);
                }
                catch (Exception ex)
                {
                    Global.Error.Write(ex);
                    CPViewPage.Message.ListMessage.Add(ex.Message);
                    return false;
                }

                return true;
            }

            return false;
        }
Exemplo n.º 11
0
 private int GetMaxOrder(SysTemplateModel model)
 {
     return SysTemplateService.Instance.CreateQuery()
             .Where(o => o.LangID == model.LangID)
             .Max(o => o.Order)
             .ToValue().ToInt(0) + 1;
 }
Exemplo n.º 12
0
 public void ActionSaveNew(SysTemplateModel model)
 {
     if (ValidSave(model))
         SaveNewRedirect(model.RecordID, entity.ID);
 }
Exemplo n.º 13
0
 public void ActionSave(SysTemplateModel model)
 {
     if (ValidSave(model))
         SaveRedirect();
 }
Exemplo n.º 14
0
 public void ActionApply(SysTemplateModel model)
 {
     if (ValidSave(model))
         ApplyRedirect(model.RecordID, entity.ID);
 }