コード例 #1
0
        public IHttpActionResult Post(CourseManagerPostRequest requestData)
        {
            var requestService = new Service.Utility.RequestDataHelper <CourseManagerPostRequest>();
            var checkColumnKey = new string[4] {
                "token", "invitecode", "restype", "accounts"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <InviteResponseData>();

            response.Success = false;

            if (checkEmpty == false)
            {
                response.Message = "遺漏參數";
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var organizationService = new OrganizationService();
            var checkCanRegister    = organizationService.CheckCanRegister(requestData.OrgCode);

            if (checkCanRegister == false)
            {
                response.Message = "不允許加入課程";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Data    = new InviteResponseData()
                {
                    InviteStatus = InviteStatusEnum.EndInvite, IsOrgRegister = false, CircleKey = requestData.CircleKey
                };
                return(Ok(response));
            }
            var responseData = courseManagerService.CreateMutiple(requestData);

            response.Success = true;
            response.Message = responseData.InviteStatus.ToString();

            response.Data = responseData;
            return(Ok(response));
        }
コード例 #2
0
        public IHttpActionResult Post(CircleMemberRoleRequest requestData)
        {
            var response = new Infrastructure.ViewModel.Base.BaseResponse <string>();

            var requestService = new Service.Utility.RequestDataHelper <CircleMemberRoleRequest>();
            var checkColumnKey = new string[1] {
                "token"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);

            response.Success = false;
            if (checkEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }

            //後臺新增
            if (requestData.InviteCode == null && requestData.RoleId.HasValue)
            {
                var authService     = new AuthService();
                var checkManageAuth = authService.CheckCourseManageAuth(requestData.Token, requestData.CircleKey.ToLower());
                //除了課程管理者可以修改,其他角色都不得修改
                if (checkManageAuth == null || checkManageAuth.CircleMemberSetting.AddCircleMember == false)
                {
                    response.Message = "無法加入";
                    response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                    return(Ok(response));
                }

                var proxyReponse = circleMemberService.InsertMutipleCircleMemberRole(requestData);
                response.Success = proxyReponse;
                if (proxyReponse)
                {
                    response.Message = "新增成功";
                    return(Ok(response));
                }
                else
                {
                    response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                    response.Message = "新增失敗";
                    return(Ok(response));
                }
            }
            else
            { //邀請碼新增
                var inviteService = new MemberInviteService();
                var inviteInfo    = inviteService.GetDetail(requestData.InviteCode.ToLower());

                if (inviteInfo == null)
                {
                    response.Message = "無法加入";
                    response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                    return(Ok(response));
                }
                var inviteResponse      = new Infrastructure.ViewModel.Base.BaseResponse <InviteResponseData>();
                var organizationService = new OrganizationService();
                var checkCanRegister    = organizationService.CheckCanRegister(requestData.OrgCode);
                if (checkCanRegister == false)
                {
                    inviteResponse.Message = "不允許加入課程";
                    inviteResponse.State   = Infrastructure.ViewModel.Base.LogState.Error;
                    inviteResponse.Data    = new InviteResponseData()
                    {
                        InviteStatus = InviteStatusEnum.EndInvite, IsOrgRegister = false, CircleKey = requestData.CircleKey
                    };
                    return(Ok(inviteResponse));
                }

                var responseData = circleMemberService.InsertCircleMemberRoleByInvite(requestData);

                inviteResponse.Success = true;
                inviteResponse.Data    = responseData;
                inviteResponse.Message = responseData.InviteStatus.ToString();
                return(Ok(inviteResponse));
            }
        }