Exemplo n.º 1
0
 public ActionResult Search()
 {
     return(ForView(new UserSearchVM()
     {
         Depts = DeptBD.GetRefList(o => o.Corp.Id == GetLoginCorpId())
     }));
 }
Exemplo n.º 2
0
        protected override void OnViewExecuting(object viewModel)
        {
            var l = DeptBD.GetRefList(o => o.Corp.Id == GetLoginCorpId());

            SetViewModel <UserEditVM>(m => m.Depts   = l);
            SetViewModel <UserSearchVM>(m => m.Depts = l);
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            var dept = DeptBD.Get(id);
            var m    = new DeptEditVM
            {
                Input = Map <Dept, DeptEditVM.EditInput>(dept)
            };

            foreach (var func in dept.Corp.Funcs)
            {
                m.Input.CorpFuncIds = m.Input.CorpFuncIds + "," + func.Id;
            }
            if (m.Input.CorpFuncIds != "")
            {
                m.Input.CorpFuncIds = m.Input.CorpFuncIds.Substring(1);
            }
            foreach (var func in dept.Funcs)
            {
                m.Input.DeptFuncIds = m.Input.DeptFuncIds + "," + func.Id;
            }
            if (m.Input.DeptFuncIds != "")
            {
                m.Input.DeptFuncIds = m.Input.DeptFuncIds.Substring(1);
            }
            m.CanChangeDeptFunc = IsAdmin();
            return(ForView(m));
        }
Exemplo n.º 4
0
        private int Save(DeptEditVM.EditInput input, bool changeDeptFunc)
        {
            Dept dept;

            if (input.Id == 0)
            {
                dept       = new Dept();
                dept.Corp  = GetLoginCorp();
                dept.Funcs = new DomainList <Func>();
            }
            else
            {
                dept = DeptBD.Get(input.Id);
            }
            if (!AdminCode.Equals(dept.Code, StringComparison.OrdinalIgnoreCase))
            {
                dept.Code = input.Code;
            }
            dept.Name = input.Name;
            if (IsAdmin() && changeDeptFunc)
            {
                dept.Funcs.Clear();
                if (!string.IsNullOrEmpty(input.DeptFuncIds))
                {
                    Array.ForEach(input.DeptFuncIds.Split(','), o => dept.Funcs.Add(FuncBD.Get(int.Parse(o))));
                }
            }
            DeptBD.Save(dept);
            return(dept.Id);
        }
Exemplo n.º 5
0
        public ActionResult Delete(DeptListVM listvm)
        {
            throw new Exception("eee");
            corp = GetLoginCorp();
            foreach (var id in listvm.Input.SelectedValues)
            {
                DeptBD.Delete(id);
            }

            return(List(listvm));
        }
Exemplo n.º 6
0
 public ActionResult DeleteInLine(int id)
 {
     DeptBD.Delete(id);
     return(RcJson(true));
 }