bool IsUpdataRepeat(role r)
        {
            GetRole     gr     = new GetRole();
            List <role> rl     = gr.getrole();
            List <role> temprl = rl.FindAll(p => p.roleName == r.roleName);

            foreach (role re in temprl)
            {
                if (re != null && re.guid != r.guid)
                {
                    MessageAlert.Alert("该名称已经存在!");
                    return(true);
                }
            }
            temprl = rl.FindAll(p => p.roleDM == r.roleDM);
            foreach (role re in temprl)
            {
                if (re != null && re.guid != r.guid)
                {
                    MessageAlert.Alert("该编号已经存在!");
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
        public ActionResult Create(WebManageUsers entity, FormCollection form)
        {
            if (GetRole == null || GetDept == null)
            {
                ModelState.AddModelError("", "请把表单填写完整...");
                return(View());
            }

            if (userRepository.Find(i => i.LoginName == entity.LoginName) != null)
            {
                ModelState.AddModelError("", "名称不能重复...");
                return(View());
            }

            entity.Operator       = "";
            entity.WebManageRoles = roleRepository.GetModel(i => GetRole.Contains(i.Id)).ToList();
            entity.WebDepartments = departmentsRepository.GetModel(i => GetDept.Contains(i.Id)).ToList();
            if (ModelState.IsValid)
            {
                entity.Password = Lind.DDD.Utils.Encryptor.Utility.EncryptString(entity.Password, Utils.Encryptor.Utility.EncryptorType.MD5);
                userRepository.Insert(entity);
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "请把表单填写完整...");
                return(View(entity));
            }
        }
예제 #3
0
        public void BindRole(ComboBox cb)
        {
            GetRole     gr = new GetRole();
            List <role> rl = new List <role>();

            rl                   = gr.getrole();
            cb.ItemsSource       = rl;
            cb.DisplayMemberPath = "roleName";
            cb.SelectedValuePath = "id";
        }
예제 #4
0
        public SignupView()
        {
            InitializeComponent();

            SignupPresenter presenter = new SignupPresenter(this);

            AcceptButton = buttonCreate;

            Load += (_, e) =>
            {
                GetRole?.Invoke(this, e);
                LoadComboBoxRole();
            };

            InitControls();
        }
        bool IsExit(role r, int count = 0)
        {
            GetRole     gr = new GetRole();
            List <role> rl = gr.getrole();

            if (rl.FindAll(p => p.roleName == r.roleName).Count > count)
            {
                MessageAlert.Alert("该名称已经存在!");
                return(true);
            }

            if (rl.FindAll(p => p.roleDM == r.roleDM).Count > count)
            {
                MessageAlert.Alert("该编号已经存在!");
                return(true);
            }
            return(false);
        }
예제 #6
0
        public ActionResult Edit(int id, WebManageUsers entity, FormCollection form)
        {
            ModelState.Remove("Password");
            if (userRepository.Find(i => i.LoginName == entity.LoginName && i.Id != entity.Id) != null)
            {
                ModelState.AddModelError("", "名称不能重复...");
                return(View(new WebManageUsers {
                    Id = id
                }));
            }

            var old = userRepository.GetModel()
                      .Include(i => i.WebDepartments)
                      .Include(i => i.WebManageRoles)
                      .FirstOrDefault(i => i.Id == id);

            old.WebManageRoles = roleRepository.GetModel(i => GetRole.Contains(i.Id)).ToList();
            old.WebDepartments = departmentsRepository.GetModel(i => GetDept.Contains(i.Id)).ToList();
            old.LoginName      = entity.LoginName;
            old.ThridUserId    = entity.ThridUserId;
            old.RealName       = entity.RealName;
            old.Mobile         = entity.Mobile;
            old.Email          = entity.Email;
            old.Description    = entity.Description;
            if (ModelState.IsValid)
            {
                userRepository.Update(old);
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "请把表单填写完整...");
                return(View(new WebManageUsers {
                    Id = id
                }));
            }
        }
예제 #7
0
 public async Task <RoleModel> GetRoleAsync([FromBody] GetRole getRole)
 {
     return(await _mediator.Send(getRole));
 }