Exemplo n.º 1
0
        public object PostAddEdit(DepartmentMemberAddEditDTO departmentMemberVM)
        {
            departmentMemberVM.Roles = base.MyRequest.Form["Roles"].ToStringObj().Split(',').Select(c => new QueryModel(c.ToString(), "")).ToList();
            ResultOperation resultOperation = new ResultOperation();

            using (DepartmentMemberService departmentMemberService = new DepartmentMemberService())
            {
                List <sysBpmsDepartmentMember> list = departmentMemberService.GetList(departmentMemberVM.DepartmentID, null, departmentMemberVM.UserID);
                foreach (var item in list.Where(c => !departmentMemberVM.Roles.Select(d => d.Key).Contains(c.RoleLU.ToString())))
                {
                    if (resultOperation.IsSuccess)
                    {
                        resultOperation = departmentMemberService.Delete(item.ID);
                    }
                }
                foreach (var item in departmentMemberVM.Roles.Where(c => !list.Any(d => d.RoleLU == c.Key.ToIntObj())))
                {
                    if (resultOperation.IsSuccess)
                    {
                        sysBpmsDepartmentMember newMember = new sysBpmsDepartmentMember();
                        newMember.Update(departmentMemberVM.DepartmentID, departmentMemberVM.UserID, item.Key.ToIntObj());
                        resultOperation = departmentMemberService.Add(newMember);
                    }
                }
            }
            if (resultOperation.IsSuccess)
            {
                return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
            }
            else
            {
                return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
            }
        }
Exemplo n.º 2
0
 public object GetList([System.Web.Http.FromUri] DepartmentMemberIndexSearchDTO indexSearchVM)
 {
     using (DepartmentMemberService departmentMemberService = new DepartmentMemberService())
     {
         indexSearchVM.Update(departmentMemberService.GetList(indexSearchVM.DepartmentID, null, null, indexSearchVM.GetPagingProperties).Select(c => new DepartmentMemberListDTO(c)).ToList());
     }
     return(indexSearchVM);
 }