コード例 #1
0
        private async Task <bool> CreateOrUpdateTaskAsync(string apiAccessToken)
        {
            if (taskHead != null)
            {
                if (taskHead.Id != Guid.Empty)
                {
                    var response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Get, APITypes.TASK, $"Task/{taskHead.Id}");

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        var foundTaskHead = response.ContentAsType <TaskHead>();

                        if (foundTaskHead != null)
                        {
                            if (!await _modelHelper.ProcessPatch(foundTaskHead, taskHead, foundTaskHead.Id, apiAccessToken, APITypes.TASK, "Task"))
                            {
                                return(false);
                            }

                            response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Get, APITypes.TASK, $"Task/Detail/{taskHead.TaskDetail.Id}");

                            if (response.StatusCode == System.Net.HttpStatusCode.OK)
                            {
                                var foundTaskDet = response.ContentAsType <TaskDet>();

                                if (foundTaskDet != null)
                                {
                                    if (!await _modelHelper.ProcessPatch(foundTaskDet, taskHead.TaskDetail, foundTaskDet.Id, apiAccessToken, APITypes.TASK, "Task/Detail"))
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    HttpContent contentPost = new StringContent(JsonConvert.SerializeObject(taskHead), Encoding.UTF8, "application/json");

                    try
                    {
                        var response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Post, APITypes.TASK, $"Task", contentPost);

                        if (response.StatusCode != System.Net.HttpStatusCode.Created)
                        {
                            return(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        var responseString = $"Error calling API: {ex.Message}";
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #2
0
        private async Task <bool> CreateOrUpdateTextCodeAsync(string apiAccessToken)
        {
            if (langHead != null)
            {
                if (langHead.Id != Guid.Empty)
                {
                    var response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Get, APITypes.FOUNDATION, $"Language/{langHead.Id}");

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        var foundLangHead = response.ContentAsType <LangHead>();

                        if (foundLangHead != null)
                        {
                            if (!await _modelHelper.ProcessPatch(foundLangHead, langHead, foundLangHead.Id, apiAccessToken, APITypes.FOUNDATION, "Language"))
                            {
                                return(false);
                            }
                        }

                        foreach (var langItem in langHead.LanguageItems)
                        {
                            if (!await CreateOrUpdateLanguageItemAsync(langItem, apiAccessToken))
                            {
                                return(false);
                            }
                        }
                    }
                }
                else
                {
                    HttpContent contentPost = new StringContent(JsonConvert.SerializeObject(langHead), Encoding.UTF8, "application/json");

                    try
                    {
                        var response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Post, APITypes.FOUNDATION, $"Language", contentPost);

                        if (response.StatusCode != System.Net.HttpStatusCode.Created)
                        {
                            return(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        var responseString = $"Error calling API: {ex.Message}";
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #3
0
        private async Task <bool> CreateOrUpdateFileAsync(string apiAccessToken)
        {
            if (FileUploadModel.FileHeader != null)
            {
                if (FileUploadModel.FileHeader.Id != Guid.Empty)
                {
                    var response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Get, APITypes.FILE, $"File/{FileUploadModel.FileHeader.Id}");

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        var foundFileHeader = response.ContentAsType <FileHead>();

                        if (foundFileHeader != null)
                        {
                            if (!await _modelHelper.ProcessPatch(foundFileHeader, FileUploadModel.FileHeader, foundFileHeader.Id, apiAccessToken, APITypes.FILE, "File"))
                            {
                                return(false);
                            }

                            if (!await _modelHelper.ProcessPatch(foundFileHeader.FileDetail, FileUploadModel.FileHeader.FileDetail, foundFileHeader.FileDetail.Id, apiAccessToken, APITypes.FILE, "File/Detail"))
                            {
                                return(false);
                            }
                        }
                    }
                }
                else
                {
                    HttpContent contentPost = new StringContent(JsonConvert.SerializeObject(FileUploadModel.FileHeader), Encoding.UTF8, "application/json");

                    try
                    {
                        var response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Post, APITypes.FILE, $"File", contentPost);

                        if (response.StatusCode != HttpStatusCode.Created)
                        {
                            return(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        var responseString = $"Error calling API: {ex.Message}";
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #4
0
        private async Task <bool> UpdateUser(string accessToken)
        {
            var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.IDENTITY, $"User/{userProfileModel.userModel.Id.ToString()}");

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var foundUserModel = response.ContentAsType <UserModel>();

                if (foundUserModel != null)
                {
                    if (!await _modelHelper.ProcessPatch(foundUserModel, userProfileModel.userModel, foundUserModel.Id, accessToken, APITypes.IDENTITY, "User"))
                    {
                        return(false);
                    }
                }
            }

            return(await CreateOrUpdateUserTeamJoins(accessToken));
        }
コード例 #5
0
        private async Task <bool> CreateOrUpdateSystemSettingAsync(string apiAccessToken)
        {
            if (tenSetting != null)
            {
                if (tenSetting.Id != Guid.Empty)
                {
                    var response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Get, APITypes.FOUNDATION, $"Setting/{tenSetting.Id}");

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        var foundSystemSetting = response.ContentAsType <TenSetting>();

                        if (foundSystemSetting != null)
                        {
                            if (!await _modelHelper.ProcessPatch(foundSystemSetting, tenSetting, foundSystemSetting.Id, apiAccessToken, APITypes.FOUNDATION, "Setting"))
                            {
                                return(false);
                            }
                        }
                    }
                }
                else
                {
                    HttpContent contentPost = new StringContent(JsonConvert.SerializeObject(tenSetting), Encoding.UTF8, "application/json");

                    try
                    {
                        var response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Post, APITypes.FOUNDATION, $"Setting", contentPost);

                        if (response.StatusCode != System.Net.HttpStatusCode.Created)
                        {
                            return(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        var responseString = $"Error calling API: {ex.Message}";
                        return(false);
                    }
                }
            }

            return(true);
        }