Esempio n. 1
0
        public bool SetUserInfo(UserRequest UserInfo)
        {
            OrganizationRequest OrganizationRequest = new OrganizationRequest();

            OrganizationRequest.Organization.OrganizationKey = UserInfo.Organization.OrganizationKey;
            bool IsSet = false;

            try
            {
                Epi.Web.Interfaces.DataInterfaces.IUserDao IUserDao = new EF.EntityUserDao();
                Epi.Web.BLL.User Implementation = new Epi.Web.BLL.User(IUserDao);

                Epi.Web.Interfaces.DataInterfaces.IOrganizationDao IOrganizationDao = new EF.EntityOrganizationDao();
                Epi.Web.BLL.Organization OrgImplementation = new Epi.Web.BLL.Organization(IOrganizationDao);


                OrganizationBO OrganizationBO = OrgImplementation.GetOrganizationByKey(UserInfo.Organization.OrganizationKey);

                IsSet = Implementation.SetUserInfo(Mapper.ToUserBO(UserInfo.User), OrganizationBO);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(IsSet);
        }
Esempio n. 2
0
        public UserResponse SetUserInfo(UserRequest request)
        {
            try
            {
                UserResponse response = new UserResponse();

                Epi.Web.BLL.Organization organizationImplementation = new Epi.Web.BLL.Organization(_organizationDao);

                Epi.Web.BLL.User userImplementation = new Epi.Web.BLL.User(_userDao);
                UserBO           userBO             = request.User.ToUserBO();
                OrganizationBO   orgBo = request.Organization.ToOrganizationBO();
                if (request.Action.ToUpper() == "UPDATE")
                {
                    OrganizationBO organizationBO = organizationImplementation.GetOrganizationByOrgId(request.CurrentOrg);
                    userBO.Operation = OperationMode.UpdateUserInfo;
                    userImplementation.UpdateUser(userBO, organizationBO);
                }
                else
                {
                    UserBO existingUser = userImplementation.GetUserByEmail(userBO);//Validate if user is in the system.
                    bool   UserExists   = false;
                    if (existingUser != null)
                    {
                        OrganizationBO OrganizationBO = organizationImplementation.GetOrganizationByOrgId(request.CurrentOrg);
                        existingUser.Role     = userBO.Role;
                        existingUser.IsActive = userBO.IsActive;
                        userBO     = existingUser;
                        UserExists = userImplementation.IsUserExistsInOrganizaion(userBO, OrganizationBO); //validate if user is part of the organization already.
                    }

                    if (!UserExists)
                    {
                        //OrgBo.OrganizationId = request.CurrentOrg; // User is added to the current organization
                        OrganizationBO organizationBO = organizationImplementation.GetOrganizationByOrgId(request.CurrentOrg);
                        userImplementation.SetUserInfo(userBO, organizationBO);
                        response.Message = "Success";
                    }
                    else
                    {
                        response.Message = "Exists";
                    }
                }

                return(response);
            }
            catch (Exception ex)
            {
                throw new FaultException <CustomFaultException>(new CustomFaultException(ex));
            }
        }