/// <summary>
        /// Gets the client bank Id, office bank Id and partner member Id based on the branch and dept id
        /// </summary>
        /// <param name="oHostSecurityToken">The Host Security Token from IWS</param>
        /// <param name="branchOrganisationId">The branch organisation id.</param>
        /// <param name="departmentId">The department id.</param>
        /// <returns></returns>
        public DepartmentReturnValue GetDepartment(HostSecurityToken oHostSecurityToken, int deptId)
        {
            DepartmentReturnValue departmentReturnValue = new DepartmentReturnValue();

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oBranchDeptService    = new BranchDeptService();
                departmentReturnValue = oBranchDeptService.GetDepartment(Functions.GetLogonIdFromToken(oHostSecurityToken), deptId);
            }
            else
            {
                departmentReturnValue         = new DepartmentReturnValue();
                departmentReturnValue.Success = false;
                departmentReturnValue.Message = "Invalid Token";
            }
            return(departmentReturnValue);
        }
        public DepartmentReturnValue GetDepartment(Guid logonId, int deptId)
        {
            dsDepartments dsDepartmentReturnValue = new dsDepartments();
            DepartmentReturnValue departmentReturnValue = new DepartmentReturnValue();
            departmentReturnValue.Department = new Department();
            //DsBranches branchReturnValue = new DsBranches();
            //OrganisationReturnValue organisationReturnValue = new OrganisationReturnValue();
            //dsDepartments departmentReturnValue = new dsDepartments();
            //DsWorkTypes workTypeReturnValue = new DsWorkTypes();
            //EarnerReturnValue earnerReturnValue = new EarnerReturnValue();
            //DsPersons personReturnValue = new DsPersons();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    dsDepartmentReturnValue = SrvDepartmentLookup.GetDepartMentOnDepartmentId(deptId);

                    departmentReturnValue.Department.DeptArchived = dsDepartmentReturnValue.Tables[0].Rows[0]["DeptArchived"].ToString();
                    departmentReturnValue.Department.DeptId = int.Parse(dsDepartmentReturnValue.Tables[0].Rows[0]["DeptId"].ToString());
                    departmentReturnValue.Department.DeptName = dsDepartmentReturnValue.Tables[0].Rows[0]["DeptName"].ToString();
                    departmentReturnValue.Department.DeptNo = dsDepartmentReturnValue.Tables[0].Rows[0]["DeptNo"].ToString();

                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                departmentReturnValue.Success = false;
                departmentReturnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                departmentReturnValue.Success = false;
                departmentReturnValue.Message = ex.Message;
            }

            return departmentReturnValue;
        }
        public DepartmentReturnValue GetDepartment(Guid logonId, int deptId)
        {
            dsDepartments         dsDepartmentReturnValue = new dsDepartments();
            DepartmentReturnValue departmentReturnValue   = new DepartmentReturnValue();

            departmentReturnValue.Department = new Department();
            //DsBranches branchReturnValue = new DsBranches();
            //OrganisationReturnValue organisationReturnValue = new OrganisationReturnValue();
            //dsDepartments departmentReturnValue = new dsDepartments();
            //DsWorkTypes workTypeReturnValue = new DsWorkTypes();
            //EarnerReturnValue earnerReturnValue = new EarnerReturnValue();
            //DsPersons personReturnValue = new DsPersons();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                    case DataConstants.UserType.Staff:
                        // Can do everything
                        break;

                    case DataConstants.UserType.Client:
                    case DataConstants.UserType.ThirdParty:
                        throw new Exception("Access denied");

                    default:
                        throw new Exception("Access denied");
                    }

                    dsDepartmentReturnValue = SrvDepartmentLookup.GetDepartMentOnDepartmentId(deptId);

                    departmentReturnValue.Department.DeptArchived = dsDepartmentReturnValue.Tables[0].Rows[0]["DeptArchived"].ToString();
                    departmentReturnValue.Department.DeptId       = int.Parse(dsDepartmentReturnValue.Tables[0].Rows[0]["DeptId"].ToString());
                    departmentReturnValue.Department.DeptName     = dsDepartmentReturnValue.Tables[0].Rows[0]["DeptName"].ToString();
                    departmentReturnValue.Department.DeptNo       = dsDepartmentReturnValue.Tables[0].Rows[0]["DeptNo"].ToString();
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                departmentReturnValue.Success = false;
                departmentReturnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                departmentReturnValue.Success = false;
                departmentReturnValue.Message = ex.Message;
            }

            return(departmentReturnValue);
        }
 /// <summary>
 /// Gets the client bank Id, office bank Id and partner member Id based on the branch and dept id
 /// </summary>
 /// <param name="oHostSecurityToken">The Host Security Token from IWS</param>
 /// <param name="branchOrganisationId">The branch organisation id.</param>
 /// <param name="departmentId">The department id.</param>
 /// <returns></returns>
 public DepartmentReturnValue GetDepartment(HostSecurityToken oHostSecurityToken, int deptId)
 {
     DepartmentReturnValue departmentReturnValue = new DepartmentReturnValue();
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oBranchDeptService = new BranchDeptService();
         departmentReturnValue = oBranchDeptService.GetDepartment(Functions.GetLogonIdFromToken(oHostSecurityToken), deptId);
     }
     else
     {
         departmentReturnValue = new DepartmentReturnValue();
         departmentReturnValue.Success = false;
         departmentReturnValue.Message = "Invalid Token";
     }
     return departmentReturnValue;
 }