Example #1
0
        public IHttpActionResult Post(MemberInvitePostRequest requestData)
        {
            var requestService = new RequestDataHelper <MemberInvitePostRequest>();
            var checkColumnKey = new string[4] {
                "token", "circlekey", "roletype", "inviteemail"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <bool>();

            response.Success = false;

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

            response.Data = responseData;
            if (responseData)
            {
                response.Success = true;
                response.Message = "建立成功";
            }
            else
            {
                response.Message = "建立失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
            }
            return(Ok(response));
        }
Example #2
0
        public IHttpActionResult Put(MemberInvitePutRequest requestData)
        {
            var requestService = new RequestDataHelper <MemberInvitePutRequest>();
            var checkColumnKey = new string[1] {
                "token"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <List <MemberInvite> >();

            response.Success = false;
            response.Data    = new List <MemberInvite>();
            if (checkEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var responseData = memberInviteService.Update(requestData);

            if (responseData != null)
            {
                response.Success = true;
                response.Message = "更新成功";
                response.Data    = responseData.ToList();
            }
            else
            {
                response.Message = "更新失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
            }
            return(Ok(response));
        }
        public IHttpActionResult Get([FromUri] string strAccess)
        {
            var requestData    = JsonConvert.DeserializeObject <MemberInvitePostRequest>(strAccess);
            var requestService = new RequestDataHelper <MemberInvitePostRequest>();
            var checkColumnKey = new string[3] {
                "token", "circlekey", "invitetype"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <bool>();

            response.Success = false;
            if (checkEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var responseData = memberInviteService.GetLearningInviteStatus(requestData.Token, requestData.CircleKey.ToLower(), requestData.InviteType);

            response.Data    = responseData;
            response.Success = true;
            if (responseData)
            {
                response.Message = "啟用邀請";
            }
            else
            {
                response.Message = "停用邀請";
            }
            return(Ok(response));
        }
        public IHttpActionResult Put([FromBody] MemberInvitePostRequest requestData)
        {
            var requestService = new RequestDataHelper <MemberInvitePostRequest>();
            var checkColumnKey = new string[3] {
                "token", "circlekey", "invitetype"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <bool>();

            response.Success = false;

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

            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 responseData = memberInviteService.UpdateLearningInviteStatus(requestData.Token, requestData.CircleKey.ToLower(), requestData.InviteType);

            response.Data    = responseData;
            response.Success = true;
            if (responseData)
            {
                response.Message = "啟用邀請";
            }
            else
            {
                response.Message = "停用邀請";
            }
            return(Ok(response));
        }
Example #5
0
        /// <summary>
        /// 取得邀請碼資訊
        /// </summary>
        /// <param name="strAccess"></param>
        /// <returns></returns>
        public IHttpActionResult Get(string strAccess)
        {
            var requestData    = JsonConvert.DeserializeObject <MemberInviteGetRequest>(strAccess);
            var requestService = new RequestDataHelper <MemberInviteGetRequest>();
            var checkColumnKey = new string[3] {
                "token", "circlekey", "ismaincode"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <IEnumerable <Infrastructure.Entity.MemberInvite> >();

            response.Success = false;
            response.Data    = new List <Infrastructure.Entity.MemberInvite>();
            if (checkEmpty == false)
            {
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                response.Message = "遺漏參數";
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var responseData = memberInviteService.GetList(requestData.CircleKey.ToLower(), 0, null);

            if (requestData.IsMainCode)
            {
                responseData = responseData.Where(t => t.Enable == true && t.IsCourseCode == true);
            }
            if (responseData == null)
            {
                response.Message = "查無資訊";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
            }
            else
            {
                response.Success = true;
                response.Message = "查詢成功";
                response.Data    = responseData;
            }
            return(Ok(response));
        }