Ejemplo n.º 1
0
        public async Task <IActionResult> OnGetAsync()
        {
            langCode = new LangCode();
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            await PageConstructor(SaveStates.IGNORE, accessToken);

            if (!string.IsNullOrWhiteSpace(Id))
            {
                var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.FOUNDATION, $"Language/Code/{Id}");

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    langCode = response.ContentAsType <LangCode>();
                }
            }

            SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken);

            return(Page());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync()
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            await PageConstructor(SaveStates.IGNORE, accessToken);

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.FOUNDATION, $"Setting/{Id}");

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                tenSetting = response.ContentAsType <TenSetting>();
            }
            else
            {
                tenSetting = new TenSetting();
            }

            SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken);

            return(Page());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnGetAsync()
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            await PageConstructor(SaveStates.IGNORE, accessToken);

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            taskGroupHead            = new TaskGroupHead();
            taskGroupHead.MainUserId = Guid.Parse(User.FindFirst("sub").Value);

            if (!string.IsNullOrWhiteSpace(Id))
            {
                if (Guid.TryParse(Id, out Guid parsedId))
                {
                    if (parsedId != Guid.Empty)
                    {
                        var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.TASK, $"TaskGroup/{Id}");

                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            taskGroupHead = response.ContentAsType <TaskGroupHead>();
                            if (taskGroupHead != null)
                            {
                                ParentId = taskGroupHead.ParentTaskGroupId.ToString();
                            }
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrWhiteSpace(ParentId))
                        {
                            var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.TASK, $"TaskGroup/{ParentId}");

                            if (response.StatusCode == System.Net.HttpStatusCode.OK)
                            {
                                taskGroupHead                   = response.ContentAsType <TaskGroupHead>();
                                taskGroupHead.ShortName         = string.Empty;
                                taskGroupHead.LongName          = string.Empty;
                                taskGroupHead.Description       = string.Empty;
                                taskGroupHead.ParentTaskGroupId = taskGroupHead.Id;
                                taskGroupHead.Id                = Guid.Empty;
                            }
                        }
                    }
                }
            }
            else
            {
                Id = Guid.Empty.ToString();
            }

            SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken);

            return(Page());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> OnGetAsync()
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            await PageConstructor(SaveStates.IGNORE, accessToken);

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            if (!string.IsNullOrWhiteSpace(Id))
            {
                if (Guid.TryParse(Id, out Guid parsedId))
                {
                    if (parsedId != Guid.Empty)
                    {
                        var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.FILE, $"File/Version/{parsedId}");

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

                            if (fileVersion != null)
                            {
                                return(File(fileVersion.Content, MediaTypeNames.Application.Octet, fileVersion.TrustedName));
                            }
                        }
                    }
                }
            }

            return(Page());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> OnGetAsync()
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            await PageConstructor(SaveStates.IGNORE, accessToken);

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.CLIENT, $"Client");

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                clientList = response.ContentAsType <ClientList>();
            }
            else
            {
                clientList = new ClientList();
            }

            //var response2 = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.GATEWAY, $"Client");

            //if (response2.StatusCode == System.Net.HttpStatusCode.OK)
            //{
            //    var clientList2 = response.ContentAsType<ClientList>();
            //}


            SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken);

            return(Page());
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> OnGetAsync()
        {
            usersViewModel = new UsersViewModel();

            var accessToken = await HttpContext.GetTokenAsync("access_token");

            await PageConstructor(SaveStates.IGNORE, accessToken);

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.IDENTITY, $"User");

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

                usersViewModel = _mapper.Map <UsersViewModel>(userListModel);
            }

            SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken);

            return(Page());
        }
Ejemplo n.º 7
0
        private async Task <bool> CreateOrUpdateUserSettingAsync(string apiAccessToken)
        {
            if (userLanguageSetting != null)
            {
                if (userLanguageSetting.Id != Guid.Empty)
                {
                    var foundUserLanguageSetting = await GetUserSetting("USER_LANGUAGE", apiAccessToken);

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

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

                        if (response.StatusCode != System.Net.HttpStatusCode.Created)
                        {
                            return(false);
                        }

                        userLanguageSetting = response.ContentAsType <UsrSetting>();
                    }
                    catch (Exception ex)
                    {
                        ErrorString = $"Error calling API: {ex.Message}";
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> OnGetAsync()
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            FileUploadModel = new FileUploadModel();

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            if (!string.IsNullOrWhiteSpace(Id))
            {
                if (Guid.TryParse(Id, out Guid parsedId))
                {
                    if (parsedId != Guid.Empty)
                    {
                        var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.FILE, $"File/{parsedId}");

                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            FileUploadModel.FileHeader = response.ContentAsType <FileHead>();
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrWhiteSpace(linkId) && !string.IsNullOrWhiteSpace(linkType))
                        {
                            FileUploadModel.linkId   = Guid.Parse(linkId);
                            FileUploadModel.linkType = linkType;
                        }
                    }
                }
            }

            await PageConstructor(SaveStates.IGNORE, accessToken);

            SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken);

            return(Page());
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> OnGetAsync()
        {
            teamHead = new TeamHead();

            var accessToken = await HttpContext.GetTokenAsync("access_token");

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            if (!string.IsNullOrWhiteSpace(Id))
            {
                var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.TEAM, $"Team/{Id}");

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    teamHead = response.ContentAsType <TeamHead>();
                }
            }
            else
            {
                Id = Guid.Empty.ToString();
                var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            }

            await PageConstructor(SaveStates.IGNORE, accessToken);

            SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken);

            return(Page());
        }
        public async Task <ActionResult> OnGetAsync()
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            string base64Image = Base64Images.PanacheSoftwareDot;

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            if (!string.IsNullOrWhiteSpace(Id))
            {
                if (Guid.TryParse(Id, out Guid foundId))
                {
                    if (foundId != Guid.Empty)
                    {
                        var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.IDENTITY, $"User/{foundId.ToString()}");

                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            base64Image = response.ContentAsType <UserModel>().Base64ProfileImage;
                        }
                        //ApplicationUser applicationUser = await _userManager.FindByIdAsync(Id);

                        //if (applicationUser != null)
                        //{

                        //    base64Image = applicationUser.Base64ProfileImage;
                        //}
                    }
                }
            }

            var contentType = Regex.Match(base64Image, @"data:(.+?);").Groups[1].Value;
            var imageString = base64Image.Substring(base64Image.IndexOf($"data:{contentType};base64,") + $"data:{contentType};base64,".Length);

            byte[] bytes = Convert.FromBase64String(imageString);

            return(File(bytes, contentType));
        }
        public async Task <IActionResult> OnGetAsync()
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            userProfileModel.userModel       = new UserModel();
            userProfileModel.password        = string.Empty;
            userProfileModel.passwordConfirm = string.Empty;

            if (!string.IsNullOrWhiteSpace(Id))
            {
                if (Guid.TryParse(Id, out Guid foundId))
                {
                    if (foundId != Guid.Empty)
                    {
                        var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.IDENTITY, $"User/{foundId.ToString()}");

                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            userProfileModel.userModel = response.ContentAsType <UserModel>();
                        }
                    }
                }
            }

            await PageConstructor(SaveStates.IGNORE, accessToken);

            //userTeamTableModel.StatusList = StatusList;
            //userTeamTableModel.userProfileModel = userProfileModel;

            //await CreateTeamSelectList(accessToken);
            //await CreateUserTeamModelList(accessToken);

            //await GeneratePageConstructionModel();

            SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken);

            return(Page());
        }
Ejemplo n.º 12
0
        public async Task <bool> ProcessPatch(object existingObject, object updatedObject, Guid objectId, string accessToken, string apiType, string urlPrefix)
        {
            var jsonPatchDocument = new JsonPatchDocument();

            if (jsonPatchDocument.GeneratePatch(existingObject, updatedObject))
            {
                var         test        = JsonConvert.SerializeObject(jsonPatchDocument);
                HttpContent contentPost = new StringContent(JsonConvert.SerializeObject(jsonPatchDocument), Encoding.UTF8, "application/json");

                try
                {
                    var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Patch, apiType, $"{urlPrefix}/{objectId.ToString()}", contentPost);

                    return(true);
                }
                catch (Exception ex)
                {
                    var responseString = $"Error calling API: {ex.Message}";
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> OnGetAsync()
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            await PageConstructor(SaveStates.IGNORE, accessToken);

            FileVersionUploadModel = new FileVersionUploadModel();
            FileHead fileHead = new FileHead();

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            if (!string.IsNullOrWhiteSpace(fileHeaderId))
            {
                if (Guid.TryParse(fileHeaderId, out Guid parsedId))
                {
                    if (parsedId != Guid.Empty)
                    {
                        var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.FILE, $"File/{parsedId}");

                        if (response.StatusCode == HttpStatusCode.OK)
                        {
                            fileHead = response.ContentAsType <FileHead>();
                        }
                    }
                }
            }

            if (fileHead != null)
            {
                if (!string.IsNullOrWhiteSpace(Id))
                {
                    if (Guid.TryParse(Id, out Guid parsedId))
                    {
                        if (parsedId != Guid.Empty)
                        {
                            FileVersionUploadModel.FileVersion = fileHead.FileVersions.Where(v => v.Id == parsedId).FirstOrDefault();
                        }
                    }
                }

                FileVersionUploadModel.FileTitle   = fileHead.FileDetail.FileTitle;
                FileVersionUploadModel.Description = fileHead.FileDetail.FileTitle;

                if (FileVersionUploadModel.FileVersion == null)
                {
                    FileVersionUploadModel.FileVersion = new FileVer()
                    {
                        FileHeaderId = fileHead.Id
                    };
                }
                else
                {
                    FileVersionUploadModel.FileVersion.FileHeaderId = fileHead.Id;
                }
            }

            SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken, SaveState);

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync()
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            await PageConstructor(SaveStates.IGNORE, accessToken);

            if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
            {
                return(RedirectToPage("/Logout"));
            }

            taskGroupSummary = new TaskGroupSummary();
            clientSummary    = new ClientSummary();

            if (!string.IsNullOrWhiteSpace(Id))
            {
                var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.TASK, $"TaskGroup/GetTaskGroupSummary/{Id}");

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    taskGroupSummary = response.ContentAsType <TaskGroupSummary>();
                }
                else
                {
                    return(RedirectToPage("/TaskGroup/TaskGroups"));
                }
            }
            else
            {
                return(RedirectToPage("/TaskGroup/TaskGroups"));
            }

            if (taskGroupSummary != null)
            {
                await GetFileLinks(accessToken);

                var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.CLIENT, $"Client/GetClientSummary/{taskGroupSummary.ClientHeaderId}");

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    clientSummary = response.ContentAsType <ClientSummary>();
                }

                GanttDataModel = GanttHelper.GenerateGanttDataModel(taskGroupSummary);
            }
            else
            {
                GanttDataModel = new GanttDataModel()
                {
                    Data  = new GanttData[0],
                    Links = new GanttLink[0]
                };
            }

            var userList = await GetUsernames(accessToken);

            //Temporary fix for adding language code data to partial pages.
            taskGroupSummary.langQueryList = taskGroupSummarylangQueryList;
            taskGroupSummary.MainUserName  = userList.Users.Where(u => u.Id == taskGroupSummary.MainUserId).FirstOrDefault().FullName;

            foreach (var childTaskGroupSummary in taskGroupSummary.ChildTaskGroups)
            {
                childTaskGroupSummary.langQueryList = taskGroupSummarylangQueryList;
                childTaskGroupSummary.MainUserName  = userList.Users.Where(u => u.Id == childTaskGroupSummary.MainUserId).FirstOrDefault().FullName;

                foreach (var childTaskSummary in childTaskGroupSummary.ChildTasks)
                {
                    childTaskSummary.langQueryList = taskSummarylangQueryList;
                    childTaskSummary.MainUserName  = userList.Users.Where(u => u.Id == childTaskSummary.MainUserId).FirstOrDefault().FullName;
                }
            }

            foreach (var childTaskSummary in taskGroupSummary.ChildTasks)
            {
                childTaskSummary.langQueryList = taskGroupSummarylangQueryList;
                childTaskSummary.MainUserName  = userList.Users.Where(u => u.Id == childTaskSummary.MainUserId).FirstOrDefault().FullName;
            }

            GanttJSON = JsonSerializer.Serialize(GanttDataModel);

            SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken);

            return(Page());
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                var accessToken = await HttpContext.GetTokenAsync("access_token");

                await PageConstructor(SaveStates.IGNORE, accessToken);

                if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value))
                {
                    return(RedirectToPage("/Logout"));
                }

                if (!string.IsNullOrWhiteSpace(taskGroupId))
                {
                    if (Guid.TryParse(taskGroupId, out Guid parsedId))
                    {
                        if (parsedId != Guid.Empty)
                        {
                            var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.TASK, $"TaskGroup/{parsedId}");

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

                                if (!string.IsNullOrWhiteSpace(taskId))
                                {
                                    if (Guid.TryParse(taskGroupId, out Guid parsedTaskId))
                                    {
                                        if (parsedTaskId != Guid.Empty)
                                        {
                                            var childTask = taskGroupHead.ChildTasks.Where(c => c.Id == parsedTaskId).FirstOrDefault();

                                            if (childTask != null)
                                            {
                                                response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.TASK, $"Task/Complete/{parsedTaskId}");

                                                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                                                {
                                                    return(RedirectToPage($"/TaskGroup/{taskGroupHead.Id}"));
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.TASK, $"TaskGroup/Complete/{parsedId}");

                                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                                    {
                                        if (taskGroupHead.ParentTaskGroupId != null)
                                        {
                                            return(RedirectToPage($"/TaskGroup/{taskGroupHead.ParentTaskGroupId}"));
                                        }
                                        else
                                        {
                                            return(RedirectToPage($"/TaskGroup/{taskGroupHead.Id}"));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(RedirectToPage("/TaskGroup/TaskGroups"));
                }

                return(RedirectToPage("/TaskGroup/TaskGroups"));
            }

            return(RedirectToPage("/TaskGroup/TaskGroups"));
        }