Пример #1
0
        public IHttpActionResult Exists(string type, string key, string value, string p1 = "")
        {
            bool result = false;

            switch (type)
            {
            case "EmpIdNo":
            {
                BaseRequest <EmployeeFilter> request = new BaseRequest <EmployeeFilter>();
                request.Data.OrgId = SecurityHelper.CurrentPrincipal.OrgId;
                request.Data.IdNo  = value;
                IOrganizationManageService service = IOCContainer.Instance.Resolve <IOrganizationManageService>();
                var response = service.QueryEmployee(request);
                if (response.Data.Count > 0)
                {
                    result = ((List <Employee>)response.Data).Any(it => it.EmpNo != key);
                }
                break;
            }

            case "RegIdNo":
            {
                BaseRequest <PersonFilter> request = new BaseRequest <PersonFilter>();
                request.Data.OrgId = SecurityHelper.CurrentPrincipal.OrgId;
                request.Data.IdNo  = value;
                IResidentManageService service = IOCContainer.Instance.Resolve <IResidentManageService>();
                var response = service.QueryPerson(request);
                if (response.Data.Count > 0)
                {
                    result = ((List <Person>)response.Data).Any(it => it.RegNo != int.Parse(key));
                }
                break;
            }

            case "ResidengNo":
            {
                BaseRequest <PersonFilter> request = new BaseRequest <PersonFilter>();
                request.Data.OrgId      = SecurityHelper.CurrentPrincipal.OrgId;
                request.Data.ResidengNo = value;
                IResidentManageService service = IOCContainer.Instance.Resolve <IResidentManageService>();
                var response = service.QueryPerson(request);
                if (response.Data.Count > 0)
                {
                    result = ((List <Person>)response.Data).Any(it => it.RegNo != int.Parse(key));
                }
                break;
            }

            case "FloorId":
            {
                BaseRequest <OrgFloorFilter> request = new BaseRequest <OrgFloorFilter>();
                request.Data.OrgId   = SecurityHelper.CurrentPrincipal.OrgId;
                request.Data.FloorId = value;
                IOrganizationManageService service = IOCContainer.Instance.Resolve <IOrganizationManageService>();
                var response = service.QueryOrgFloor(request);
                if (response.Data.Count > 0)
                {
                    result = ((List <OrgFloor>)response.Data).Any(it => it.FloorId != key);
                }
                break;
            }

            case "RoomNo":
            {
                BaseRequest <OrgRoomFilter> request = new BaseRequest <OrgRoomFilter>();
                request.Data.OrgId  = SecurityHelper.CurrentPrincipal.OrgId;
                request.Data.RoomNo = value;
                IOrganizationManageService service = IOCContainer.Instance.Resolve <IOrganizationManageService>();
                var response = service.QueryOrgRoom(request);
                if (response.Data.Count > 0)
                {
                    result = ((List <OrgRoom>)response.Data).Any(it => it.RoomNo != key);
                }
                break;
            }

            case "DeptNo":
            {
                BaseRequest <DeptFilter> request = new BaseRequest <DeptFilter>();
                request.Data.OrgId  = SecurityHelper.CurrentPrincipal.OrgId;
                request.Data.DeptNo = value;
                IOrganizationManageService service = IOCContainer.Instance.Resolve <IOrganizationManageService>();
                var response = service.QueryDept(request);
                if (response.Data.Count > 0)
                {
                    result = ((List <Dept>)response.Data).Any(it => it.DeptNo != key);
                }
                break;
            }

            case "BedNo":
            {
                BaseRequest <BedBasicFilter> request = new BaseRequest <BedBasicFilter>();
                request.Data.OrgId = SecurityHelper.CurrentPrincipal.OrgId;
                request.Data.BedNo = value;
                IOrganizationManageService service = IOCContainer.Instance.Resolve <IOrganizationManageService>();
                var response = service.QueryBedBasic(request);
                if (response.Data.Count > 0)
                {
                    result = ((List <BedBasic>)response.Data).Any(it => it.BedNo != key);
                }
                break;
            }

            case "RoleName":
            {
                BaseRequest <RoleFilter> request = new BaseRequest <RoleFilter>();
                request.Data.RoleName = value;
                request.Data.OrgId    = p1;
                IOrganizationManageService service = IOCContainer.Instance.Resolve <IOrganizationManageService>();
                var response = service.QueryRole(request);
                if (response.Data.Count > 0)
                {
                    result = ((List <Role>)response.Data).Any(it => it.RoleId != key);
                }
                break;
            }

            case "CostItemNo":
            {
                BaseRequest <CostItemFilter> request = new BaseRequest <CostItemFilter>();
                request.Data.OrgId      = SecurityHelper.CurrentPrincipal.OrgId;
                request.Data.CostItemNo = value;
                ICostManageService service = IOCContainer.Instance.Resolve <ICostManageService>();
                var response = service.QueryCostItem(request);
                if (response.Data.Count > 0)
                {
                    result = ((List <CostItem>)response.Data).Any(it => it.CostItemNo != key);
                }
                break;
            }
            }
            return(Ok(result));
        }