/// <summary>
        /// Handle get all projects from api call
        /// </summary>
        /// <returns> IEnumerable with all the projects from the api. returns null if something happened</returns>
        public IEnumerable <ProjectModel> GetAllProjects()
        {
            var projectsResponse = Get("/api/v2/projects");

            if (!_responseHandler.CheckForErrorResponse(projectsResponse))
            {
                return(null);
            }

            var ownProjects = _responseHandler.ListOfObjectsResponse <ProjectModel>(projectsResponse, "OwnProjects");
            var projects    = _responseHandler.ListOfObjectsResponse <ProjectModel>(projectsResponse, "Projects");

            return(projects.Concat(ownProjects));
        }
        /// <summary>
        /// Handle create new user api call
        /// </summary>
        /// <param name="user">User model obj</param>
        /// <returns>Bool true if was success. false if there is something wrong</returns>
        public bool Register(UserModel user)
        {
            if (string.IsNullOrEmpty(user.Name) || string.IsNullOrEmpty(user.Email) || string.IsNullOrEmpty(user.Password) || string.IsNullOrEmpty(user.RepeatPassword))
            {
                MessageBox.Show("Don't leave the fields empty");
                return(false);
            }

            var response = Post <UserModel>("/api/v2/users", user);

            if (!_responseHandler.CheckForErrorResponse(response))
            {
                MessageBox.Show("successfully created a new account");
                return(true);
            }

            MessageBox.Show("Register failed try again!");
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Handle add a new backlog item api call
        /// </summary>
        /// <param name="backlogItem"> A new backlog item model </param>
        /// <param name="projectSlug"> Slug of the project</param>
        /// <returns>Bool true on success. false when something went wrong</returns>
        public bool AddBacklogItem(BacklogItemModel backlogItem, string projectSlug)
        {
            if (string.IsNullOrEmpty(backlogItem.Action) || string.IsNullOrEmpty(backlogItem.UserRole))
            {
                MessageBox.Show("Don't leave the fields empty");
                return(false);
            }

            var response = Post <BacklogItemModel>($"/api/v2/project/{projectSlug}/backlog_items", backlogItem);

            if (_responseHandler.CheckForErrorResponse(response))
            {
                return(true);
            }

            MessageBox.Show("Something went wrong with Creating a backlog item please try again!");
            return(false);
        }
        /// <summary>
        /// Handle create a sprint api call
        /// </summary>
        /// <param name="sprint"> Model of the new sprint</param>
        /// <returns> Boolean true if the api call was a success false if there where complications</returns>
        public bool CreateSprint(SprintModel sprint)
        {
            if (string.IsNullOrEmpty(sprint.Name) || string.IsNullOrEmpty(sprint.StartDate) || string.IsNullOrEmpty(sprint.EndDate))
            {
                MessageBox.Show("Don't leave the fields empty");
                return(false);
            }

            var response = Post <SprintModel>($"/api/v2/project/{sprint.ProjectSlug}/sprint", sprint);

            if (_responseHandler.CheckForErrorResponse(response))
            {
                return(true);
            }

            MessageBox.Show("Error when creating a sprint please try again!");
            return(false);
        }