示例#1
0
        public IHttpActionResult Get(string strAccess)
        {
            var requestData    = JsonConvert.DeserializeObject <BackendBaseRequest>(strAccess);
            var requestService = new Service.Utility.RequestDataHelper <BackendBaseRequest>();

            var response = new ResultBaseModel <ExternalResource>();

            response.Success = false;
            response.Data    = new ExternalResource[0];
            var checkColumnKeys = new string[1] {
                "token"
            };
            var checkDataEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkDataEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var externalResourceService = new ExternalResourceService();
            var responseData            = externalResourceService.GetListByRequest(requestData);

            if (responseData == null)
            {
                response.Message = "查詢失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(response));
            }
            response.Message = "查詢成功";
            response.Success = true;
            response.Data    = responseData.ToArray();
            return(Ok(response));
        }
示例#2
0
        public IHttpActionResult Delete(string strAccess)
        {
            var requestData    = JsonConvert.DeserializeObject <Infrastructure.ViewModel.CourseManage.CourseManagerDeleteRequest>(strAccess);
            var requestService = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.CourseManage.CourseManagerDeleteRequest>();
            var checkColumnKey = new string[2] {
                "circlekey", "token"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <bool>();

            response.Success = false;
            response.Data    = false;
            if (checkEmpty == false)
            {
                response.Message = "請確認是否遺漏";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var responseData = courseManagerService.DeleteMutiple(requestData);

            response.Data = responseData;
            if (responseData)
            {
                response.Success = true;
                response.Message = "刪除成功";
            }
            else
            {
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Message = "刪除失敗";
            }
            return(Ok(response));
        }
示例#3
0
        public IHttpActionResult Get(string strAccess)
        {
            var requestData    = JsonConvert.DeserializeObject <Infrastructure.ViewModel.Base.BackendBaseRequest>(strAccess);
            var requestService = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.Base.BackendBaseRequest>();
            var checkColumnKey = new string[2] {
                "circlekey", "token"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <List <Infrastructure.ViewModel.CourseManage.CourseManagerGetResponse> >();

            response.Success = false;
            response.Data    = new List <Infrastructure.ViewModel.CourseManage.CourseManagerGetResponse>();
            if (checkEmpty == false)
            {
                response.Message = "請確認是否遺漏";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var responseData = courseManagerService.GetManagers(requestData.Token, requestData.CircleKey);

            if (responseData == null)
            {
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Message = "無課程管理者";
                return(Ok(response));
            }
            response.Data    = responseData;
            response.Message = "查詢成功";
            response.Success = true;
            return(Ok(response));
        }
示例#4
0
        public IHttpActionResult Get(string strAccess)
        {
            var requestData    = JsonConvert.DeserializeObject <Infrastructure.ViewModel.Base.BackendBaseRequest>(strAccess);
            var requestService = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.Base.BackendBaseRequest>();
            var checkColumnKey = new string[2] {
                "token", "circlekey"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <List <LearningRoleGetResponse> >();

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

            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));
        }
示例#5
0
        public IHttpActionResult Delete(string strAccess)
        {
            var requestData     = JsonConvert.DeserializeObject <OrganizationDeleteRequest>(strAccess);
            var requestService  = new Service.Utility.RequestDataHelper <OrganizationDeleteRequest>();
            var response        = new Infrastructure.ViewModel.Base.BaseResponse <bool>();
            var checkColumnKeys = new string[2] {
                "token", "id"
            };
            var checkDataEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkDataEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                response.Success = false;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var orgService   = new OrganizationService();
            var responseData = orgService.DeleteOrganization(requestData);

            response.Data = responseData;
            if (responseData == false)
            {
                response.Success = false;
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Message = "刪除失敗";
                return(Ok(response));
            }
            response.Success = true;
            response.Message = "刪除成功";
            return(Ok(response));
        }
示例#6
0
        public IHttpActionResult Get(string strAccess)
        {
            var requestService = new Service.Utility.RequestDataHelper <BackendBaseRequest>();
            var requestData    = JsonConvert.DeserializeObject <BackendBaseRequest>(strAccess);
            var checkColumKey  = new string[2] {
                "account", "icantoken"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <string>();

            response.Success = false;
            if (checkEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var tokenService = new TokenService();
            var responseData = tokenService.SetPushCountClear(requestData.ICanToken.ToLower());

            if (responseData)
            {
                response.Success = true;
                response.Message = "修改成功";
                return(Ok(response));
            }
            response.Message = "修改失敗";
            return(Ok(response));
        }
        public IHttpActionResult Get(string strAccess)
        {
            var requestData     = JsonConvert.DeserializeObject <OrganizationRoleGetRequest>(strAccess);
            var requestService  = new Service.Utility.RequestDataHelper <OrganizationRoleGetRequest>();
            var response        = new Infrastructure.ViewModel.Base.BaseResponse <List <OrganizationRole> >();
            var checkColumnKeys = new string[2] {
                "token", "orgcode"
            };
            var checkDataEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkDataEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                response.Success = false;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var organizationRoleService = new OrganizationRoleService();
            var responseData            = organizationRoleService.GetListByRequest(requestData);

            if (responseData == null)
            {
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Success = false;
                response.Message = "查詢失敗";
                return(Ok(response));
            }
            response.Success = true;
            response.Message = "查詢成功";
            response.Data    = responseData;
            return(Ok(response));
        }
示例#8
0
        public IHttpActionResult Put(Infrastructure.ViewModel.Login.LoginRequest requestData)
        {
            var requestService = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.Login.LoginRequest>();
            var checkColumnKey = new string[2] {
                "account", "pushtoken"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <string>();

            if (checkEmpty == false)
            {
                response.Success = false;
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var tokenService = new TokenService();
            var responseMsg  = tokenService.UpdateMemberPushToken(requestData.Account, requestData.PushToken);

            if (responseMsg == false)
            {
                response.Success = false;
                response.Message = "修改失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(response));
            }

            response.Success = true;
            response.Message = "修改成功";

            return(Ok(response));
        }
        public IHttpActionResult Post(OrganizationRolePostRequest requestData)
        {
            var requestService  = new Service.Utility.RequestDataHelper <OrganizationRolePostRequest>();
            var response        = new Infrastructure.ViewModel.Base.BaseResponse <List <OrganizationRole> >();
            var checkColumnKeys = new string[3] {
                "token", "orgcode", "orgRoles"
            };
            var checkDataEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkDataEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                response.Success = false;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var organizationRoleService = new OrganizationRoleService();
            var responseData            = organizationRoleService.PostByRequest(requestData);

            if (responseData == null)
            {
                response.Success = false;
                response.Message = "處理失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(response));
            }
            response.Success = true;
            response.Message = "處理成功";
            response.Data    = responseData;
            return(Ok(response));
        }
        public IHttpActionResult Post(SyllabusManagePostRequest requestData)
        {
            var requestService  = new Service.Utility.RequestDataHelper <SyllabusManagePostRequest>();
            var checkColumnKeys = new string[3] {
                "token", "circleKey", "syllabuses"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);
            var result     = new Infrastructure.ViewModel.Base.BaseResponse <List <Infrastructure.Entity.Syllabus> >();

            //取得資料
            if (checkEmpty == false)
            {
                result.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                result.Success = false;
                result.Message = "確認是否遺漏資訊";
                return(Content(HttpStatusCode.BadRequest, result));
            }

            var syllabusService = new SyllabusService();
            var data            = syllabusService.SyllabusesDataProxy(requestData);


            if (data == null)
            {
                result.State   = Infrastructure.ViewModel.Base.LogState.Error;
                result.Success = false;
                result.Message = "新增失敗";
                return(Ok(result));
            }
            result.Success = true;
            result.Message = "新增成功";
            result.Data    = data;
            return(Ok(result));
        }
        public IHttpActionResult Post(LearningTemplateRolePostRequest requestData)
        {
            var requestService  = new Service.Utility.RequestDataHelper <LearningTemplateRolePostRequest>();
            var response        = new Infrastructure.ViewModel.Base.BaseResponse <List <LearningTemplateRoles> >();
            var checkColumnKeys = new string[2] {
                "token", "orgcode"
            };
            var checkDataEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkDataEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                response.Success = false;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var learningTemplateRoleService = new LearningTemplateRoleService();
            var responseData = learningTemplateRoleService.DataProxy(requestData);

            if (responseData == null)
            {
                response.Success = false;
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Message = "處理資料失敗";
                return(Ok(response));
            }
            response.Success = true;
            response.Data    = responseData;
            response.Message = "處理資料成功";
            return(Ok(response));
        }
示例#12
0
        public IHttpActionResult Post(ExternalResourcePostRequest requestData)
        {
            var requestService = new Service.Utility.RequestDataHelper <ExternalResourcePostRequest>();
            var response       = new BaseResponse <List <ExternalResource> >();

            response.Success = false;
            response.Data    = new List <ExternalResource>();
            var checkColumnKeys = new string[2] {
                "token", "orgcode"
            };
            var checkDataEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkDataEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var externalResourceService = new ExternalResourceService();
            var responseData            = externalResourceService.DataProxy(requestData);

            if (responseData == null)
            {
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Message = "資料處理錯誤";
                return(Ok(response));
            }
            response.Success = true;
            response.Message = "資料處理成功";
            response.Data    = responseData;
            return(Ok(response));
        }
示例#13
0
        public IHttpActionResult Post(TimeTablePostRequest requestData)
        {
            var requestService  = new Service.Utility.RequestDataHelper <TimeTablePostRequest>();
            var checkColumnKeys = new string[3] {
                "token", "circlekey", "timetable"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <string>();

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

            if (responseData)
            {
                response.Success = true;
                response.Message = "處理資料成功";
                return(Ok(response));
            }
            response.Message = "處理資料失敗";
            response.State   = Infrastructure.ViewModel.Base.LogState.Error;
            return(Ok(response));
        }
示例#14
0
        public IHttpActionResult Get(string strAccess)
        {
            var orgService      = new OrganizationService();
            var requestData     = JsonConvert.DeserializeObject <OrganizationGetRequest>(strAccess);
            var requestService  = new Service.Utility.RequestDataHelper <OrganizationGetRequest>();
            var response        = new Infrastructure.ViewModel.Base.BaseResponse <List <Organization> >();
            var checkColumnKeys = new string[1] {
                "token"
            };
            var checkDataEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

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

            Int32.TryParse(requestData.Search, out orgId);
            var responseData = orgId > 0 ? orgService.GetOrganization(requestData.Token, requestData.Search, orgId) : orgService.GetOrganization(requestData.Token, requestData.Search, null);

            if (responseData == null)
            {
                response.Message = "查詢失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Success = false;
                return(Ok(response));
            }
            response.Data    = responseData.ToList();
            response.Success = true;
            response.Message = "查詢成功";
            return(Ok(response));
        }
示例#15
0
        public IHttpActionResult Get(string strAccess)
        {
            var requestData    = JsonConvert.DeserializeObject <BackendBaseRequest>(strAccess);
            var requestService = new Service.Utility.RequestDataHelper <BackendBaseRequest>();
            var checkColumns   = new string[2] {
                "token", "circlekey"
            };
            //var getHeadToken = ActionContext.Request.Headers.GetValues("X-Token");
            var checkEmptData = requestService.CheckColumnEmpty(requestData, checkColumns);
            var response      = new BaseResponse <CourseManageAuthResponse>();

            response.Success = false;
            response.Data    = new CourseManageAuthResponse()
            {
                CircleAdminSetting = new CircleAdminSettingAuth()
                {
                    Admin = false, DeleteCircleAdmin = false
                },
                CircleInfoSetting = new CircleInfoSettingAuth()
                {
                    Admin = false
                },
                CircleMemberSetting = new CircleMemberSettingAuth()
                {
                    Admin = false, AddCircleMember = false, DeleteCircleMember = false
                },
                CircleRoleSetting = new CircleRoleSettingAuth()
                {
                    Admin = false, AddCircleRole = false, DeleteCircleRole = false
                },
                CircleScheduleSetting = new CircleScheduleSettingAuth()
                {
                    Admin = false
                },
                CircleTimelistSetting = new CircleTimelistSettingAuth()
                {
                    Admin = false
                }
            };
            if (checkEmptData == false)
            {
                response.Success = false;
                response.Message = "遺漏參數";
                response.State   = LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var authService  = new AuthService();
            var responseData = authService.CheckCourseManageAuth(requestData.Token, requestData.CircleKey.ToLower());

            response.Success = true;
            if (responseData == null)
            {
                response.Message = "無權限";
                return(Ok(response));
            }
            response.Message = "查詢成功";
            response.Data    = responseData;
            return(Ok(response));
        }
示例#16
0
        public IHttpActionResult Get(string strAccess)
        {
            var requestService = new Service.Utility.RequestDataHelper <WeekTablePostRequest>();
            var requestData    = JsonConvert.DeserializeObject <WeekTablePostRequest>(strAccess);
            var checkColumnKey = new string[2] {
                "token", "circlekey"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <List <TimeTable> >();

            response.Success = false;
            response.Data    = new List <TimeTable>();
            if (checkEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var tokenService = new TokenService();
            var checkToken   = tokenService.GetTokenInfo(requestData.Token).Result;

            if (checkToken == null)
            {
                response.Message = "已登出";
                response.State   = Infrastructure.ViewModel.Base.LogState.Logout;
                return(Ok(response));
            }
            var responseData = new List <TimeTable>();

            if (requestData.WeekTableData != null && requestData.WeekTableData.WeekTable.Count() > 0)
            {
                var dateTimeTools = new Service.Utility.DateTimeTools();
                responseData = dateTimeTools.GetTimeTableByWeekTable(requestData);
            }
            else
            {
                var timetableService = new TimeTableService();
                var searchData       = timetableService.GetList(requestData.CircleKey.ToLower());
                if (searchData != null)
                {
                    responseData = searchData.ToList();
                }
            }

            if (responseData == null)
            {
                response.Message = "查無資料";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(response));
            }
            response.Success = true;
            response.Message = "查詢成功";
            response.Data    = responseData;
            return(Ok(response));
        }
示例#17
0
        /// <summary>
        /// 依照不同請求方式從 actionContext 取回指定的資料
        /// </summary>
        /// <param name="actionContext"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetValueByKey(HttpActionContext actionContext, string key)
        {
            string value = null;
            object obj   = value;

            /*   if (!actionContext.ActionArguments.TryGetValue(key, out obj))
             *     return null;*/
            //從request body 或 queryString中取值
            if (actionContext.ActionArguments.Count != 0)
            {
                var requestService = new Service.Utility.RequestDataHelper <KeyValuePair <string, object> >();
                foreach (var columnKey in actionContext.ActionArguments)
                {
                    //  if (columnKey.Key.ToString().ToLower() == key.ToLower()) {
                    var checkKey = requestService.CheckColumnEmpty(columnKey, key.ToLower());
                    if (checkKey != null)
                    {
                        value = checkKey;
                    }
                    //  }
                }
                if (value == null)
                {
                    return(null);
                }
            }
            else //取得FormData
            {
                var request = actionContext.Request.Content.ReadAsStringAsync().Result;
                if (!string.IsNullOrEmpty(request))
                {
                    if (!actionContext.Request.Content.IsMimeMultipartContent())
                    {
                        NameValueCollection data = HttpUtility.ParseQueryString(request);
                        value = data[key];
                    }
                    else
                    {
                        var multipart = actionContext.Request.Content.ReadAsMultipartAsync().Result;
                        foreach (var httpContent in multipart.Contents)
                        {
                            var name = httpContent.Headers.ContentDisposition.Name.Split('"')[1];
                            if (string.Equals(name, key))
                            {
                                value = httpContent.ReadAsStringAsync().Result;
                                break;
                            }
                        }
                    }
                }
            }

            return(value);
        }
示例#18
0
        public IHttpActionResult Post(LearningCirclePostRequest requestData)
        {
            var result          = new Infrastructure.ViewModel.Base.BaseResponse <Infrastructure.Entity.LearningCircle>();
            var requestService  = new Service.Utility.RequestDataHelper <LearningCirclePostRequest>();
            var checkColumnKeys = new string[7] {
                "name", "description", "token", "startdate", "enddate", "weeks", "place"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkEmpty == false)
            {
                result.Success = false;
                result.Message = "確認是否遺漏資訊";
                return(Content(HttpStatusCode.BadRequest, result));
            }
            var service = new LearningCircleService();
            var data    = service.CreateLearningCircle(requestData.Name,
                                                       requestData.CircleKey,
                                                       requestData.Description,
                                                       requestData.Token,
                                                       requestData.StartDate.Value,
                                                       requestData.EndDate.Value,
                                                       requestData.OrgId
                                                       );

            if (data == null)
            {
                result.Success = false;
                result.Message = "新增失敗";
                result.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(result));
            }
            result.Success = true;
            var learningRoleService = new LearningRoleService();
            var authService         = new AuthService();
            //建立老師角色身分
            var teacherRole = learningRoleService.AddLearningEditRole(data.CreateUser.Value, data.Id, "老師", true, false, 1);
            //建立助教角色身分
            var surpportTeacherRole = learningRoleService.AddLearningEditRole(data.CreateUser.Value, data.Id, "助教", true, false, 2);
            //建立學生角色身分
            var studentRole = learningRoleService.AddLearningEditRole(data.CreateUser.Value, data.Id, "學生", false);
            //建立學習圈內角色權限
            var insertAuthSuccess = authService.InsertLearningCircleAllRoleAuth(data.Id, data.CreateUser.Value);

            var weekService      = new WeekTableService();
            var weekDatas        = weekService.CreateWeekDatas(requestData.Token, data.LearningOuterKey, 0, requestData.Place, requestData.StartDate.Value, requestData.EndDate.Value, requestData.Weeks);
            var timeTableService = new TimeTableService();

            var timeTableDatas = requestData.ClassWeekType > 0 ? timeTableService.CreateByCircleKey(data.LearningOuterKey, requestData.ClassWeekType) : timeTableService.CreateByCircleKey(data.LearningOuterKey);

            result.Message = "新增成功";
            result.Data    = data;
            return(Ok(result));
        }
        public IHttpActionResult Put(CircleMemberRolePutRequest requestData)
        {
            var response       = new Infrastructure.ViewModel.Base.BaseResponse <IEnumerable <CircleMemberRoleManageGetResponse> >();
            var requestService = new Service.Utility.RequestDataHelper <CircleMemberRolePutRequest>();
            var checkColumnKey = new string[4] {
                "token", "circlekey", "accounts", "roleid"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);

            response.Success = false;
            response.Data    = new List <CircleMemberRoleManageGetResponse>();
            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.Admin == false)
            {
                response.Message = "無權限修改";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(response));
            }
            //如果是課程管理者,就可以做任何事(嘿嘿嘿...
            var responseData = checkManageAuth.CircleMemberSetting.AddCircleMember == true?
                               circleMemberService.UpdateMutiple(requestData, true) :
                                   circleMemberService.UpdateMutiple(requestData);

            if (responseData)
            {
                response.Success = true;
                response.Message = "修改成功";
                var datas = circleMemberService.GetAzureCircleMemberRoleListByCircleKey(requestData.CircleKey.ToLower(), requestData.Token);
                if (datas.FirstOrDefault() != null)
                {
                    response.Data = datas;
                }
            }
            else
            {
                response.Message = "修改失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
            }
            return(Ok(response));
        }
示例#20
0
        public IHttpActionResult Post(FeedBackPostRequest requestData)
        {
            var requestService = new Service.Utility.RequestDataHelper <FeedBackPostRequest>();
            var checkColumnKey = new string[3] {
                "feedbacktype", "system", "email"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <FeedBack>();

            response.Success = false;
            response.Data    = new FeedBack();

            if (Request != null && Request.Headers.Contains("X-Token"))
            {
                requestData.Token = Request.Headers.GetValues("X-Token").FirstOrDefault();
            }
            else if (requestData.Token != string.Empty && requestData.Token != null)
            {
                requestData.Token = requestData.Token;
            }
            if (checkEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            /*判斷email格式是否有問題*/
            if (requestData.Email.Contains("@") == false)
            {
                response.Message = "email格式錯誤";
                response.State   = LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var feedBackService = new FeedBackService();
            var responseData    = feedBackService.Insert(requestData);

            if (responseData != null)
            {
                response.Success = true;
                response.Data    = responseData;
                response.Message = "新增成功";
            }
            else
            {
                response.Message = "新增失敗";
                response.State   = LogState.Error;
            }
            return(Ok(response));
        }
示例#21
0
        public IHttpActionResult Post(Infrastructure.ViewModel.School.SignInSynchronize.SignSyncClientRequest requestData)
        {
            //      var requestData = JsonConvert.DeserializeObject<Infrastructure.ViewModel.School.SignInSynchronize.SignSyncClientRequest>(strAccess);
            var requestService  = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.School.SignInSynchronize.SignSyncClientRequest>();
            var checkColumnKeys = new string[4] {
                "icantoken", "classid", "syll_id", "times"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);
            var response   = new Infrastructure.ViewModel.Base.ResultBaseModel <string>();

            response.Success = false;
            response.Data    = new string [0];
            if (checkEmpty == false)
            {
                response.State = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            requestData.Token = requestData.ICanToken;
            var tokenService = new TokenService();
            var tokenInfo    = tokenService.GetTokenInfo(requestData.Token).Result;

            if (tokenInfo == null)
            {
                response.Data    = new string[0];
                response.Message = "已登出";
                response.State   = Infrastructure.ViewModel.Base.LogState.Logout;
                return(Content(HttpStatusCode.Forbidden, response));
            }

            var signInSyncService = new SignInSyncService();
            var responseData      = signInSyncService.SyncToiCan(requestData);

            if (responseData == Infrastructure.ViewModel.Base.LogState.Suscess)
            {
                response.Success = true;
                response.Data    = new string[1] {
                    "同步成功"
                };
                response.Message = "同步成功";
            }
            else
            {
                response.Message = responseData.ToString();
                response.State   = responseData;
            }
            return(Ok(response));
        }
示例#22
0
        public IHttpActionResult Delete(string strAccess)
        {
            var requestData    = JsonConvert.DeserializeObject <LearningRoleDeleteResquest>(strAccess);
            var requestService = new Service.Utility.RequestDataHelper <LearningRoleDeleteResquest>();
            var checkColumnKey = new string[3] {
                "token", "circlekey", "ids"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <IEnumerable <LearningRoleGetResponse> >();

            response.Success = false;
            response.Data    = new List <LearningRoleGetResponse>();
            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.CircleRoleSetting.AddCircleRole == false)
            {
                response.Message = "無權限刪除";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(response));
            }
            var responseData = learningRoleService.DeleteMutiple(requestData);

            if (responseData)
            {
                var datas = learningRoleService.GetLearningRolesByCircleKey(requestData.CircleKey.ToLower(), requestData.Token);
                if (datas.FirstOrDefault() != null)
                {
                    response.Data = datas;
                }
                response.Success = true;
                response.Message = "刪除成功";
            }
            else
            {
                response.Message = "刪除失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
            }
            return(Ok(response));
        }
        public IHttpActionResult Get(string strAccess)
        {
            var requestService = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.Base.BackendBaseRequest>();
            var requestData    = JsonConvert.DeserializeObject <Infrastructure.ViewModel.Base.BackendBaseRequest>(strAccess);

            var checkColumnKey = new string[1] {
                "token"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <WeekTableViewModel>();

            response.Success = false;
            response.Data    = new WeekTableViewModel();
            if (checkEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var tokenService = new TokenService();
            var checkToken   = tokenService.GetTokenInfo(requestData.Token).Result;

            if (checkToken == null)
            {
                response.Message = "已登出";
                response.State   = Infrastructure.ViewModel.Base.LogState.Logout;
                return(Ok(response));
            }
            var weektableService = new WeekTableService();
            var responseData     = (requestData.CircleKey == null || requestData.CircleKey == string.Empty) ?
                                   weektableService.GetByToken(requestData.Token) :
                                   weektableService.GetByCirclekey(requestData.CircleKey.ToLower());

            if (responseData == null)
            {
                response.Message = "目前無課表資訊";
                response.State   = Infrastructure.ViewModel.Base.LogState.DataNotModified;
                return(Ok(response));
            }
            response.Success = true;
            response.Message = "查詢成功";
            response.Data    = responseData;
            return(Ok(response));
        }
示例#24
0
        public IHttpActionResult Get(string strAccess)
        {
            var requestData     = JsonConvert.DeserializeObject <Infrastructure.ViewModel.Base.BackendBaseRequest>(strAccess);
            var requestService  = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.Base.BackendBaseRequest>();
            var checkColumnKeys = new string[2] {
                "icantoken", "account"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <List <Infrastructure.ViewModel.School.GetLearningMapDataResponse> >();

            response.Success = false;
            response.Data    = new List <Infrastructure.ViewModel.School.GetLearningMapDataResponse>();
            if (checkEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var tokenService = new TokenService();
            var tokenInfo    = tokenService.GetTokenInfo(requestData.ICanToken).Result;

            if (tokenInfo == null)
            {
                response.Success = false;
                response.State   = Infrastructure.ViewModel.Base.LogState.Logout;
                response.Message = "已登出";
                return(Ok(response));
            }
            var learningMapService = new SceLearningMapService();
            var responseData       = learningMapService.GetData(requestData.ICanToken);

            if (responseData != null)
            {
                response.Success = true;
                response.Message = "查詢成功";
                response.Data.Add(responseData);
            }
            else
            {
                response.Success = true;
                response.Message = "老師無學習地圖資料";
            }
            return(Ok(response));
        }
示例#25
0
        public IHttpActionResult Get(string strAccess)
        {
            var requestData     = JsonConvert.DeserializeObject <Infrastructure.ViewModel.School.GetPdsFlowsRequest>(strAccess);
            var requestService  = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.School.GetPdsFlowsRequest>();
            var checkColumnKeys = new string[3] {
                "icantoken", "coll_semegrade", "id_coll"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);
            //api 140.137.200.178/API/{1}coll_semegrade[學年]/{2}ID_coll分類代碼/{3}account
            var response = new Infrastructure.ViewModel.Base.BaseResponse <List <Infrastructure.ViewModel.School.PdsFlowModel> >();

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

            var tokenService = new TokenService();
            var tokenInfo    = tokenService.GetTokenInfo(requestData.ICanToken).Result;

            if (tokenInfo == null)
            {
                response.Success = false;
                response.State   = Infrastructure.ViewModel.Base.LogState.Logout;
                response.Message = "已登出";
            }
            var pdsService   = new PDSService();
            var responseData = pdsService.GetData(requestData.Coll_SemeGrade, requestData.ID_coll, requestData.ICanToken);

            if (responseData == null)
            {
                response.Message = "查無資料";
            }
            else
            {
                response.Message = "查詢成功";
                response.Success = true;
                response.Data.Add(responseData);
            }
            return(Ok(response));
        }
        /// <summary>
        /// 刪除成員角色資料
        /// </summary>
        /// <returns></returns>
        public IHttpActionResult Delete(string strAccess)
        {
            var requestData    = JsonConvert.DeserializeObject <CircleMemberRolePutRequest>(strAccess);
            var requestService = new Service.Utility.RequestDataHelper <CircleMemberRolePutRequest>();
            var checkColumnKey = new string[3] {
                "token", "circlekey", "accounts"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <bool>();

            response.Success = false;
            response.Data    = 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.Admin == false)
            {
                response.Message = "無權限刪除";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(response));
            }
            var proxyReponse = circleMemberService.DeleteCircleMemberRole(requestData);

            response.Success = proxyReponse;
            response.Data    = proxyReponse;
            if (proxyReponse)
            {
                response.Message = "刪除成功";
            }
            else
            {
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Message = "刪除失敗";
            }
            return(Ok(response));
        }
示例#27
0
        public IHttpActionResult CheckEmpty(object checkRequest, object[] checkColumnKeys)
        {
            var requestService = new Service.Utility.RequestDataHelper <object>();
            var checkEmpty     = requestService.CheckColumnEmpty(checkRequest, checkColumnKeys);
            var response       = new Infrastructure.ViewModel.Base.BaseResponse <string>()
            {
                Success = false,
                Data    = string.Empty,
                Message = "遺漏參數",
                State   = Infrastructure.ViewModel.Base.LogState.RequestDataError
            };

            if (checkEmpty == false)
            {
                return(Content(HttpStatusCode.BadRequest, response));
            }
            response.Success = true;
            return(Content(HttpStatusCode.OK, response));
        }
示例#28
0
        public IHttpActionResult Put(FeedBackPutRequest requestData)
        {
            var requestService = new Service.Utility.RequestDataHelper <FeedBackPutRequest>();
            var checkColumnKey = new string[2] {
                "id", "status"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <FeedBack>();

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

            if (Request != null && Request.Headers.Contains("X-Token"))
            {
                requestData.Token = Request.Headers.GetValues("X-Token").FirstOrDefault();
            }
            else if (requestData.Token != string.Empty && requestData.Token != null)
            {
                requestData.Token = requestData.Token;
            }

            var feedBackService = new FeedBackService();
            var responseData    = feedBackService.Update(requestData);

            if (responseData != null)
            {
                response.Success = true;
                response.Data    = responseData;
                response.Message = "更新成功";
            }
            else
            {
                response.Message = "更新失敗";
                response.State   = LogState.Error;
            }
            return(Ok(response));
        }
    {    /// <summary>
         /// 取得課綱資訊
         /// </summary>
         /// <param name="circleKey"></param>
         /// <param name="strAccess"></param>
         /// <returns></returns>
        public IHttpActionResult Get(string strAccess)
        {
            var requestService = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.Base.BackendBaseRequest>();
            var requestData    = JsonConvert.DeserializeObject <Infrastructure.ViewModel.Base.BackendBaseRequest>(strAccess);
            var checkColumnKey = new string[2] {
                "token", "circlekey"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <List <Infrastructure.ViewModel.CourseManage.GetCourseSyllabusResponse> >();

            response.Success = false;
            response.Data    = new List <GetCourseSyllabusResponse>();
            if (checkEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var tokenService = new TokenService();
            var checkToken   = tokenService.GetTokenInfo(requestData.Token).Result;

            if (checkToken == null)
            {
                response.Message = "已登出";
                response.State   = Infrastructure.ViewModel.Base.LogState.Logout;
                return(Ok(response));
            }
            var syllabusService = new SyllabusService();
            var data            = syllabusService.APPGetCourSyllabus(requestData.Token, requestData.CircleKey.ToLower());

            if (data == null && data.Count() < 0)
            {
                response.Success = false;
                response.Message = "查詢失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(response));
            }
            response.Success = true;
            response.Message = "查詢成功";
            response.Data    = data.ToList();
            return(Ok(response));
        }
        private IHttpActionResult MakeApiCall(Infrastructure.ViewModel.Base.BackendBaseRequest requestData)
        {
            var response = new Infrastructure.ViewModel.Base.BaseResponse <List <OnlineBalanceResult> >();

            response.Data = new List <OnlineBalanceResult>();
            var requestService  = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.Base.BackendBaseRequest>();
            var checkColumnKeys = new string[2] {
                "account", "icantoken"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkEmpty == false)
            {
                response.Success = false;
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                response.Message = "參數傳遞錯誤(strAccess)";
            }
            var tokenService = new TokenService();
            var tokenInfo    = tokenService.GetTokenInfo(requestData.ICanToken).Result;

            if (tokenInfo == null)
            {
                response.Success = false;
                response.State   = Infrastructure.ViewModel.Base.LogState.Logout;
                response.Message = "已登出";
            }
            var getOnlineBalance = Convert.ToDecimal(uDollarService.GetuDollarData("GetOnlineBalance", requestData.Account));
            var getOrderAmount   = uDollarService.GetuDollarData("GetOrderAmountResult", requestData.Account, false);
            var errorMsg         = JsonConvert.DeserializeObject <List <uDollarErrorMsg> >(uDollarService.GetuDollarData("ParaDefintion", requestData.Account, false));
            var responseData     = new OnlineBalanceResult()
            {
                account             = requestData.Account,
                orderAmount         = getOrderAmount != "0" ? Convert.ToInt32(getOrderAmount) : 0,
                uDollarAmount       = getOnlineBalance >= 0 ? getOnlineBalance : 0,
                uPursePerhapsBlance = 0
            };

            response.Message = getOnlineBalance < 0 ? errorMsg.FirstOrDefault(t => t.Value == getOnlineBalance).Description : "查詢成功";
            response.Data.Add(responseData);
            response.Success = getOnlineBalance >= 0 ? true : false;
            return(Ok(response));
        }