コード例 #1
0
        public async Task <ActionResult> CreateIssue()
        {
            // View model
            MyIssuesViewModel model = new MyIssuesViewModel();

            // Store new Issue
            model.Issue = new Issue();

            // Initialize and store all users
            model.UserList = new List <User>();
            model.UserList = await _userRepository.GetAllUsers();

            // Initialize and store all projects
            model.ProjectList = new List <string>();


            string UserID = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;

            User user = await _userRepository.GetUser(UserID);

            if (user.Projects != null)
            {
                foreach (var project in user.Projects)
                {
                    model.ProjectList.Add(project);
                }
            }


            //model.ProjectList = await _projectRepository.GetAllProjects();

            return(View("CreateIssue", model));
        }
コード例 #2
0
        public MyIssuesViewController()
        {
            _viewSegment = new UISegmentedControl(new string[] { "Open".t(), "Closed".t(), "Custom".t() });
            _viewSegment.ControlStyle = UISegmentedControlStyle.Bar;
            _segmentBarButton         = new UIBarButtonItem(_viewSegment);

            ViewModel = new MyIssuesViewModel();
            BindCollection(ViewModel.Issues, CreateElement);
            ViewModel.Bind(x => x.IsLoading, Loading);
        }
コード例 #3
0
        public async Task <ActionResult> UpdateIssue(string IDCode, string ProjectIDCode)
        {
            MyIssuesViewModel model = new MyIssuesViewModel();
            Issue             issue = await _issueRepository.GetIssue(IDCode);

            List <User> UsersNotAssignedList = new List <User>();
            List <User> UsersAssignedList    = new List <User>();
            var         allUsers             = await _userRepository.GetAllUsers();

            List <string> AssignedUsersID = new List <string>();

            //Issue issueFromDb = new Issue();

            //foreach (var issue in await _issueRepository.GetAllIssues())
            //{
            //    //if (issue.IDCode.Split(':')[0].Replace("\"", "") == issue.IDCode)
            //    //{
            //    //    issueFromDb = await _issueRepository.GetIssue(issue.IDCode);
            //    //}
            //    if (issue.ProjectIDCode == ProjectIDCode)
            //    {
            //        issueFromDb = await _issueRepository.GetIssue(issue.IDCode);

            //    }
            //}



            // Loop through all the current users assigned and add there user objects to 'UsersAssignedList'
            foreach (var user in issue.Users)
            {
                string ID = user.Split(':')[0];
                UsersAssignedList.Add(await _userRepository.GetUser(ID));
                AssignedUsersID.Add(ID);
            }



            // Loop through all the user objects, if they are not in the 'UsersAssignedList', then add them to 'UsersNotAssignedList'
            foreach (var user in allUsers)
            {
                if (!AssignedUsersID.Contains(user.ID))
                {
                    UsersNotAssignedList.Add(user);
                }
            }



            model.UsersAssignedList    = UsersAssignedList;
            model.UsersNotAssignedList = UsersNotAssignedList;
            model.Issue = issue;
            return(View("UpdateIssue", model));
        }
コード例 #4
0
        public async Task <ActionResult> CreateIssue(MyIssuesViewModel myIssuesViewModel)
        {
            if (ModelState.IsValid)
            {
                Issue issue = myIssuesViewModel.Issue;

                issue.Created = DateTime.UtcNow.ToString();
                issue.Updated = issue.Created;
                issue.Users   = new List <string>();

                if (myIssuesViewModel.IssueImages != null)
                {
                    foreach (var image in myIssuesViewModel.IssueImages)
                    {
                        if (image.Length > 0)
                        {
                            using (var ms = new MemoryStream())
                            {
                                image.CopyTo(ms);
                                var    fileBytes  = ms.ToArray();
                                string fileString = Convert.ToBase64String(fileBytes);

                                // act on the Base64 data
                                issue.ScreenshotArray  = fileBytes;
                                issue.ScreenshotString = fileString;
                            }
                        }
                    }
                }

                await _issueRepository.AddIssue(issue);

                var selectedProject = await _projectRepository.GetProject(issue.ProjectIDCode.Split(':')[0]);

                selectedProject.Issues.Add(issue.IDCode + ":" + issue.Title);

                await _projectRepository.Update(selectedProject);

                if (issue.AddUsers != null)
                {
                    foreach (var user in issue.AddUsers)
                    {
                        var User = await _userRepository.GetUser(user);

                        await _projectManagementController.AddorRmove("Add", "Issue", User, selectedProject, issue, GetAuthorizationToken()); // add param to say its adding for issue
                    }
                }
            }

            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public async Task <IActionResult> Index()
        {
            // GETTING AUTH0 USER DETAILS OF CURRENT SIGNED IN USER
            string userID = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;


            List <Issue> IssueList = new List <Issue>();

            // Model for view
            MyIssuesViewModel model = new MyIssuesViewModel();


            var currentUser = await _userRepository.GetUser(userID);



            if (currentUser.Issues == null)
            {
                currentUser.Issues = new List <string>();
            }

            foreach (var issue in currentUser.Issues)
            {
                string issueIDCode = issue.Split(':')[0].Split('-')[1];
                IssueList.Add(await _issueRepository.GetIssue(issueIDCode));
            }

            if (currentUser.Projects == null || currentUser.Projects.Count == 0)
            {
                model.UserHasProjects = false;
            }
            else
            {
                model.UserHasProjects = true;
            }


            if (model.IssueList == null)
            {
                model.IssueList = new List <Issue>();
            }

            model.IssueList = IssueList;
            return(View(model));
        }
コード例 #6
0
        public async Task <ActionResult> UpdateIssue(MyIssuesViewModel myIssuesViewModel)
        {
            Issue issue = myIssuesViewModel.Issue;

            var issueFromDb = await _issueRepository.GetIssue(issue.IDCode);

            var projectFromDb = await _projectRepository.GetProject(issueFromDb.ProjectIDCode);

            //foreach(var issueInProject in projectFromDb.Issues)
            //{
            //    if(issueInProject.Split(':')[0].Replace("\"", "") == issue.IDCode)
            //    {
            //        issueFromDb = await _issueRepository.GetIssue(issue.IDCode);
            //    }
            //}

            if (ModelState.IsValid)
            {
                // Updating 'Issue' collection
                if (projectFromDb == null || issueFromDb == null)
                {
                    return(new NotFoundResult());
                }

                issue.Id      = issueFromDb.Id;
                issue.Created = issueFromDb.Created;
                issue.Updated = DateTime.UtcNow.ToString();

                foreach (var image in myIssuesViewModel.IssueImages)
                {
                    if (image.Length > 0)
                    {
                        using (var ms = new MemoryStream())
                        {
                            image.CopyTo(ms);
                            var    fileBytes  = ms.ToArray();
                            string fileString = Convert.ToBase64String(fileBytes);

                            // act on the Base64 data
                            issue.ScreenshotArray  = fileBytes;
                            issue.ScreenshotString = fileString;
                        }
                    }
                }



                if (issue.Users == null)
                {
                    issue.Users = new List <string>();
                }

                //if (issueFromDb.DeleteIssue == false)
                //{
                // Adding Users
                if (issue.AddUsers != null && issue.DeleteIssue == false)
                {
                    foreach (var user in issue.AddUsers)
                    {
                        var User = await _userRepository.GetUser(user);

                        //issue.Users.Add((user + ": " + User.UserName));
                        //await _issueRepository.Update(issue);

                        await _projectManagementController.AddorRmove("Add", "Issue", User, projectFromDb, issue, GetAuthorizationToken()); // add param to say its adding for issue
                    }
                }

                // Remove Users
                if (issue.RemoveUsers != null || issue.DeleteIssue == true)
                {
                    foreach (var user in issue.RemoveUsers)
                    {
                        var User = await _userRepository.GetUser(user);

                        //issue.Users.Remove(user + ": " + User.UserName);
                        await _projectManagementController.AddorRmove("Remove", "Issue", User, projectFromDb, issue, GetAuthorizationToken()); // add param to say its adding for issue
                    }
                }
                //}
                //else
                //{
                //    //if (issue.Users != null)
                //    //{
                //    List<string> usersDelete = issue.Users;
                //        foreach (var user in issue.Users)
                //        {
                //            var User = await _userRepository.GetUser(user);
                //            //issue.Users.Remove(user + ": " + User.UserName);
                //            await AddorRmove("Remove", "Issue", User, projectFromDb, issue, GetAuthorizationToken()); // add param to say its adding for issue

                //        }
                //    //}
                //}

                await _issueRepository.Update(issue);

                //await AddorRmove("Update", "Issue", issue, projectFromDb, issue, GetAuthorizationToken()); // add param to say its adding for issue
            }



            return(RedirectToAction("Index"));
        }