Пример #1
0
            /// <summary>
            /// Return Department Name To Specific ID
            /// </summary>
            /// <param name="request">Department ID</param>
            /// <returns>Department Name</returns>
            public static GetDepartmentResponse GetDepartmentName(int request)
            {
                GetDepartmentResponse response = new GetDepartmentResponse();

                response.Error      = new Handler.ErrorObject();
                response.Department = new Department();
                try
                {
                    var GetDepartment = DepartmentData.Select.GetDepartmentName(request);
                    if (!GetDepartment.Item1.Error)
                    {
                        response.Department = new Department()
                        {
                            name = GetDepartment.Item2.name
                        };
                    }
                    else
                    {
                        response.Error.InfoError(GetDepartment.Item1);
                    }
                }
                catch (Exception ex)
                {
                    response.Error.InfoError(ex);
                }

                return(response);
            }
Пример #2
0
            /// <summary>
            /// Return Department Information
            /// </summary>
            /// <param name="request">Department ID</param>
            /// <returns>Department Information</returns>
            public static GetDepartmentResponse GetDepartment(GetDepartmentRequest request)
            {
                GetDepartmentResponse response = new GetDepartmentResponse();

                response.Error      = new Handler.ErrorObject();
                response.Department = new Department();
                try
                {
                    var GetDepartment = DepartmentData.Select.GetDepartment(request.DepartmentID);
                    if (!GetDepartment.Item1.Error)
                    {
                        response.Department = new Department()
                        {
                            id         = GetDepartment.Item2.id,
                            name       = GetDepartment.Item2.name,
                            detail     = GetDepartment.Item2.detail,
                            createDate = GetDepartment.Item2.createDate,
                            upDateDate = GetDepartment.Item2.upDateDate,
                            deleteDate = GetDepartment.Item2.deleteDate,
                            state      = GetDepartment.Item2.state
                        };
                    }
                    else
                    {
                        response.Error.InfoError(GetDepartment.Item1);
                    }
                }
                catch (Exception ex)
                {
                    response.Error.InfoError(ex);
                }

                return(response);
            }
Пример #3
0
        public void DepartmentUseCaseEqualTest()
        {
            GetDepartmentRequest getDepartmentRequest = new GetDepartmentRequest();

            IRepositoryFactory    repositoryFactory     = new RepositoryFactory(new DBContext());
            IActivityFactory      activityFactory       = new ActivityFactory(repositoryFactory, new ValidationRuleFactory());
            IUseCaseFactory       useCaseFactory        = new UseCaseFactory(activityFactory);
            GetDepartmentResponse getDepartmentResponse = useCaseFactory.Create <IUseCase <GetDepartmentRequest, GetDepartmentResponse> >().Execute(getDepartmentRequest);

            Assert.IsTrue(getDepartmentResponse.Departments.Count > 0);
        }
Пример #4
0
        public DepartmentInfo GetDepartmentByCode(string code)
        {
            GetDepartmentByCodeRequest request = new GetDepartmentByCodeRequest()
            {
                Code = code
            };
            GetDepartmentResponse response = CallWebService <
                IOrgUnitManagementServicev1_0, GetDepartmentByCodeRequest, GetDepartmentResponse>(
                m_service1_0, request, (s, q) => s.GetDepartmentByCode(q));

            return(response.Department);
        }
Пример #5
0
        public DepartmentInfo GetDepartment(Identifier orgUnitId)
        {
            GetDepartmentRequest request = new GetDepartmentRequest()
            {
                OrgUnitId = orgUnitId
            };
            GetDepartmentResponse response = CallWebService <
                IOrgUnitManagementServicev1_0, GetDepartmentRequest, GetDepartmentResponse>(
                m_service1_0, request, (s, q) => s.GetDepartment(q));

            return(response.Department);
        }
Пример #6
0
        /// <summary>
        /// 查询部门
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <DepartmentModel> GetDepartmentAsync(int id)
        {
            GetDepartmentResponse response = await departmentRpcClient.GetDepartmentAsync(new GeneralIdRequest
            {
                Id = id
            });

            DepartmentModel department = new DepartmentModel
            {
                DepartmentId         = response.DepartmentId,
                DepartmentName       = response.DepartmentName,
                SuperiorDepartmentId = response.SuperiorDepartmentId
            };

            return(department);
        }
        public static GetDepartmentResponse Unmarshall(UnmarshallerContext _ctx)
        {
            GetDepartmentResponse getDepartmentResponse = new GetDepartmentResponse();

            getDepartmentResponse.HttpResponse = _ctx.HttpResponse;
            getDepartmentResponse.Code         = _ctx.StringValue("GetDepartment.Code");
            getDepartmentResponse.Message      = _ctx.StringValue("GetDepartment.Message");
            getDepartmentResponse.RequestId    = _ctx.StringValue("GetDepartment.RequestId");

            GetDepartmentResponse.GetDepartment_Data data = new GetDepartmentResponse.GetDepartment_Data();
            data.CreatedAt             = _ctx.StringValue("GetDepartment.Data.CreatedAt");
            data.Description           = _ctx.StringValue("GetDepartment.Data.Description");
            data.Id                    = _ctx.StringValue("GetDepartment.Data.Id");
            data.Name                  = _ctx.StringValue("GetDepartment.Data.Name");
            data.UpdatedAt             = _ctx.StringValue("GetDepartment.Data.UpdatedAt");
            getDepartmentResponse.Data = data;

            return(getDepartmentResponse);
        }
Пример #8
0
        public async Task<OperationStatusInfo> ShowDepartment()
        {
            return await Task.Run(() =>
            {
                OperationStatusInfo operationStatusInfo = new OperationStatusInfo(operationStatus: OperationStatus.Done);
                GetDepartmentRequest getDepartmentRequest = new GetDepartmentRequest();

                try
                {
                    GetDepartmentResponse getDepartmentResponse = hubEnvironment.UseCaseFactory.Create<IUseCase<GetDepartmentRequest, GetDepartmentResponse>>().Execute(getDepartmentRequest);
                    operationStatusInfo.AttachedObject = getDepartmentResponse.Departments;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    operationStatusInfo.OperationStatus = OperationStatus.Cancelled;
                    operationStatusInfo.AttachedInfo = ex.Message;
                }

                return operationStatusInfo;
            });
        }
Пример #9
0
            /// <summary>
            /// Return Affected Row Or Error If Exist
            /// </summary>
            /// <param name="DepartmentID">Department ID</param>
            /// <param name="state">State</param>
            /// <returns>Affected Row Or Error If Exist</returns>
            public static GetDepartmentResponse DepartmentDisable(int DepartmentID, string state)
            {
                GetDepartmentResponse response = new GetDepartmentResponse();

                try
                {
                    var result = DepartmentData.Delete.DepartmentDisable(DepartmentID, state);
                    if (result.Item1.Error)
                    {
                        response.Error.InfoError(result.Item1);
                    }
                    else
                    {
                        response.Message = result.Item2;
                    }
                }
                catch (Exception ex)
                {
                    response.Error.InfoError(ex);
                }
                return(response);
            }
Пример #10
0
            /// <summary>
            /// Return Department List
            /// </summary>
            /// <returns>Department List</returns>
            public static GetDepartmentResponse GetDepartmentList()
            {
                GetDepartmentResponse response = new GetDepartmentResponse();

                response.DepartmentList = new List <Department>();
                response.Error          = new Handler.ErrorObject();

                try
                {
                    var GetDepartment = DepartmentData.Select.GetDepartment();
                    if (!GetDepartment.Item1.Error)
                    {
                        foreach (var item in GetDepartment.Item2)
                        {
                            response.DepartmentList.Add(new Department()
                            {
                                id         = item.id,
                                name       = item.name,
                                detail     = item.detail,
                                createDate = item.createDate,
                                upDateDate = item.upDateDate,
                                deleteDate = item.deleteDate,
                                state      = item.state
                            });
                        }
                    }
                    else
                    {
                        response.Error.InfoError(GetDepartment.Item1);
                    }
                }
                catch (Exception ex) {
                    response.Error.InfoError(ex);
                }
                return(response);
            }
Пример #11
0
            /// <summary>
            /// Return Affected Row Or Error If Exist
            /// </summary>
            /// <param name="request">Department Information</param>
            /// <returns>Affected Row Or Error If Exist</returns>
            public static GetDepartmentResponse Department(GetDepartmentResponse request)
            {
                GetDepartmentResponse response = new GetDepartmentResponse();

                try
                {
                    tblDepartment Department = new tblDepartment()
                    {
                        id         = request.Department.id,
                        name       = request.Department.name,
                        detail     = request.Department.detail,
                        createDate = DateTime.Now,
                        upDateDate = DateTime.Now,
                        deleteDate = null,
                        state      = "Active"
                    };

                    request.Department.state      = "Active";
                    request.Department.createDate = DateTime.Now;
                    var result = DepartmentData.Update.Department(Department);
                    if (result.Item1.Error)
                    {
                        response.Error.InfoError(result.Item1);
                    }
                    else
                    {
                        response.Message = result.Item2;
                    }
                }
                catch (Exception ex)
                {
                    response.Error.InfoError(ex);
                }

                return(response);
            }