Ejemplo n.º 1
0
 public void ActionSaveNew(SysUserModel model)
 {
     if (ValidSave(model))
     {
         SaveNewRedirect(model.RecordID, entity.ID);
     }
 }
Ejemplo n.º 2
0
 public void ActionApply(SysUserModel model)
 {
     if (ValidSave(model))
     {
         ApplyRedirect(model.RecordID, entity.ID);
     }
 }
Ejemplo n.º 3
0
 public void ActionSave(SysUserModel model)
 {
     if (ValidSave(model))
     {
         SaveRedirect();
     }
 }
Ejemplo n.º 4
0
        private bool ValidSave(SysUserModel model)
        {
            TryUpdateModel(entity);

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

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

            //kiem tra ten dang nhap
            if (entity.LoginName.Trim() == string.Empty)
            {
                CPViewPage.Message.ListMessage.Add("Nhập tên người sử dụng.");
            }

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                if (model.NewPassword != string.Empty)
                {
                    //entity.Password = HL.Lib.Global.Security.MD5(model.NewPassword);
                    entity.Password = Global.Security.GetPass(model.NewPassword);
                }

                try
                {
                    //save
                    CPUserService.Instance.Save(entity);

                    //xoa
                    CPUserRoleService.Instance.Delete(o => o.UserID == entity.ID);

                    //them
                    for (int i = 0; model.ArrRole != null && i < model.ArrRole.Length; i++)
                    {
                        CPUserRoleService.Instance.Save(new CPUserRoleEntity()
                        {
                            UserID = entity.ID,
                            RoleID = model.ArrRole[i]
                        });
                    }
                }
                catch (Exception ex)
                {
                    Global.Error.Write(ex);
                    CPViewPage.Message.ListMessage.Add(ex.Message);
                    return(false);
                }

                Utils.Clear_Cache();

                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        private bool ValidSave(SysUserModel model)
        {
            TryUpdateModel(entity);

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

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

            //kiem tra ten dang nhap
            if (entity.LoginName.Trim() == string.Empty)
                CPViewPage.Message.ListMessage.Add("Nhập tên người sử dụng.");

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                if (model.NewPassword != string.Empty)
                    entity.Password = HL.Lib.Global.Security.MD5(model.NewPassword);

                try
                {
                    //save
                    CPUserService.Instance.Save(entity);

                    //xoa
                    CPUserRoleService.Instance.Delete(o => o.UserID == entity.ID);

                    //them
                    for (int i = 0; model.ArrRole != null && i < model.ArrRole.Length; i++)
                    {
                        CPUserRoleService.Instance.Save(new CPUserRoleEntity()
                                {
                                    UserID = entity.ID,
                                    RoleID = model.ArrRole[i]
                                });
                    }
                }
                catch (Exception ex)
                {
                    Global.Error.Write(ex);
                    CPViewPage.Message.ListMessage.Add(ex.Message);
                    return false;
                }

                Utils.Clear_Cache();

                return true;
            }

            return false;
        }
Ejemplo n.º 6
0
        public void ActionIndex(SysUserModel model)
        {
            // sap xep tu dong
            string orderBy = AutoSort(model.Sort);

            // tao danh sach
            var dbQuery = CPUserService.Instance.CreateQuery()
                                .Take(model.PageSize)
                                .OrderBy(orderBy)
                                .Skip(model.PageIndex * model.PageSize);

            ViewBag.Data = dbQuery.ToList();
            model.TotalRecord = dbQuery.TotalRecord;
            ViewBag.Model = model;
        }
Ejemplo n.º 7
0
        public void ActionIndex(SysUserModel model)
        {
            // sap xep tu dong
            string orderBy = AutoSort(model.Sort);

            // tao danh sach
            var dbQuery = CPUserService.Instance.CreateQuery()
                          .Take(model.PageSize)
                          .OrderBy(orderBy)
                          .Skip(model.PageIndex * model.PageSize);

            ViewBag.Data      = dbQuery.ToList();
            model.TotalRecord = dbQuery.TotalRecord;
            ViewBag.Model     = model;
        }
Ejemplo n.º 8
0
        public void ActionAdd(SysUserModel model)
        {
            if (model.RecordID > 0)
            {
                entity = CPUserService.Instance.GetByID(model.RecordID);

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

                // khoi tao gia tri mac dinh khi insert
            }

            ViewBag.Data = entity;
            ViewBag.Model = model;
        }
Ejemplo n.º 9
0
        public void ActionAdd(SysUserModel model)
        {
            if (model.RecordID > 0)
            {
                entity = CPUserService.Instance.GetByID(model.RecordID);

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

                // khoi tao gia tri mac dinh khi insert
            }

            ViewBag.Data  = entity;
            ViewBag.Model = model;
        }
Ejemplo n.º 10
0
 public void ActionSaveNew(SysUserModel model)
 {
     if (ValidSave(model))
         SaveNewRedirect(model.RecordID, entity.ID);
 }
Ejemplo n.º 11
0
 public void ActionSave(SysUserModel model)
 {
     if (ValidSave(model))
         SaveRedirect();
 }
Ejemplo n.º 12
0
 public void ActionApply(SysUserModel model)
 {
     if (ValidSave(model))
         ApplyRedirect(model.RecordID, entity.ID);
 }