Esempio n. 1
0
 public void ActionApply(ModTourModel model)
 {
     if (ValidSave(model))
     {
         ApplyRedirect(model.RecordID, entity.ID);
     }
 }
Esempio n. 2
0
 public void ActionSaveNew(ModTourModel model)
 {
     if (ValidSave(model))
     {
         SaveNewRedirect(model.RecordID, entity.ID);
     }
 }
Esempio n. 3
0
 public void ActionSave(ModTourModel model)
 {
     if (ValidSave(model))
     {
         SaveRedirect();
     }
 }
Esempio n. 4
0
        private bool ValidSave(ModTourModel 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 ten
            if (entity.Name.Trim() == string.Empty)
            {
                CPViewPage.Message.ListMessage.Add("Nhập tên.");
            }

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

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                //neu khong nhap code -> tu sinh
                if (entity.Code.Trim() == string.Empty)
                {
                    entity.Code = Data.GetCode(entity.Name);
                }

                //cap nhat state
                entity.State = GetState(model.ArrState);

                //save
                ModTourService.Instance.Save(entity);

                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        public void ActionIndex(ModTourModel model)
        {
            // sap xep tu dong
            string orderBy = AutoSort(model.Sort);

            // tao danh sach
            var dbQuery = ModTourService.Instance.CreateQuery()
                                .Where(!string.IsNullOrEmpty(model.SearchText), o => o.Name.Contains(model.SearchText))
                                .Where(model.State > 0, o => (o.State & model.State) == model.State)
                                .WhereIn(o => o.MenuID, WebMenuService.Instance.GetChildIDForCP("Tour", 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;
        }
Esempio n. 6
0
        public void ActionIndex(ModTourModel model)
        {
            // sap xep tu dong
            string orderBy = AutoSort(model.Sort);

            // tao danh sach
            var dbQuery = ModTourService.Instance.CreateQuery()
                          .Where(!string.IsNullOrEmpty(model.SearchText), o => o.Name.Contains(model.SearchText))
                          .Where(model.State > 0, o => (o.State & model.State) == model.State)
                          .WhereIn(o => o.MenuID, WebMenuService.Instance.GetChildIDForCP("Tour", 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;
        }
Esempio n. 7
0
        public void ActionAdd(ModTourModel model)
        {
            if (model.RecordID > 0)
            {
                entity = ModTourService.Instance.GetByID(model.RecordID);

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

                // 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;
        }
Esempio n. 8
0
        public void ActionAdd(ModTourModel model)
        {
            if (model.RecordID > 0)
            {
                entity = ModTourService.Instance.GetByID(model.RecordID);

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

                // 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;
        }
Esempio n. 9
0
 private int GetMaxOrder(ModTourModel model)
 {
     return(ModTourService.Instance.CreateQuery()
            .Max(o => o.Order)
            .ToValue().ToInt(0) + 1);
 }
Esempio n. 10
0
        private bool ValidSave(ModTourModel 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 ten
            if (entity.Name.Trim() == string.Empty)
                CPViewPage.Message.ListMessage.Add("Nhập tên.");

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

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                 //neu khong nhap code -> tu sinh
                 if (entity.Code.Trim() == string.Empty)
                    entity.Code = Data.GetCode(entity.Name);

                 //cap nhat state
                entity.State = GetState(model.ArrState);

                //save
                ModTourService.Instance.Save(entity);

                return true;
            }

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