示例#1
0
        private static async Task <bool> SaveUserTypologyAsync(HttpClient httpClient, Dto.CompanyDto company, Guid departmentId, JobDataWithComp job, string progressMessage)
        {
            var userTypologyName = job.JobFunction.JobFunctionJobFunction.Text;
            var userTypology     = await GetUserTypologyAsync(httpClient, departmentId, job.JobFunction.JobFunctionJobFunction.Text);

            if (userTypology != null)
            {
                return(true);
            }
            var userTypologyGroupModel = new UserTypologyGroupModel
            {
                CompanyId = company.CompanyId,
                Name      = userTypologyName,
                Active    = true
            };
            var saveUserTypologyGroup = await SaveUserTypologyGroupAsync(httpClient, userTypologyGroupModel, progressMessage);

            if (!saveUserTypologyGroup)
            {
                return(false);
            }
            UserTypologyModel model = new UserTypologyModel
            {
                CompanyId             = company.CompanyId,
                Name                  = userTypologyName,
                ExternalId            = userTypologyName,
                DepartmentId          = departmentId,
                UserTypologyGroupName = userTypologyName,
                Active                = true,
            };
            var saveUserTypology = await SaveUserTypologyAsync(httpClient, model, progressMessage);

            return(saveUserTypology);
        }
示例#2
0
        private static async Task <bool> SaveUserTypologyGroupAsync(HttpClient httpClient, UserTypologyGroupModel model, string progressMessage)
        {
            HttpContent contentPost = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
            var         response    = await httpClient.PostAsync("/api/usertypologygroups", contentPost);

            if (response.IsSuccessStatusCode)
            {
                var userTypologyGroupDto = await response.Content.ReadAsJsonAsync <UserTypologyGroupDto>();

                await ApiHelper.SaveLogAsync(httpClient, model.CompanyCode, model.CompanyId, Updater.MyStatusId, "UserTypologyGroup", model.Name, userTypologyGroupDto.Action, progressMessage, JsonConvert.SerializeObject(model));

                return(true);
            }
            var errorMessage = response.Content.ReadAsStringAsync().Result;
            await ApiHelper.SaveLogAsync(httpClient, model.CompanyCode, model.CompanyId, Updater.MyStatusId, "UserTypologyGroup", model.Name, errorMessage, progressMessage, JsonConvert.SerializeObject(model));

            return(response.IsSuccessStatusCode);
        }