Ejemplo n.º 1
0
        /// <summary>
        /// Converts <see cref="TodoistColor"/> to <see cref="string"/>.
        /// </summary>
        /// <param name="todoistColor">
        /// The todoist color.
        /// </param>
        /// <returns>
        /// <see cref="TodoistColor"/> in <see cref="string"/>.
        /// </returns>
        /// <exception cref="InvalidEnumArgumentException">Throws <see cref="InvalidEnumArgumentException"/>
        /// if the parameter is not a valid color.</exception>
        private static string ConvertTodoistColorToString(TodoistColor todoistColor)
        {
            switch (todoistColor)
            {
            case TodoistColor.Green:
                return("bde876");

            case TodoistColor.Red:
                return("ff8581");

            case TodoistColor.Orange:
                return("ffc472");

            case TodoistColor.Yellow:
                return("faed75");

            case TodoistColor.Blue:
                return("a8c9e5");

            case TodoistColor.MediumGrey:
                return("999999");

            case TodoistColor.Pink:
                return("e3a8e5");

            case TodoistColor.LightGrey:
                return("dddddd");

            case TodoistColor.Flame:
                return("fc603c");

            case TodoistColor.Gold:
                return("ffcc00");

            case TodoistColor.LightOpal:
                return("74e8d4");

            case TodoistColor.BrilliantCerulean:
                return("3cd6fc");
            }

            throw new InvalidEnumArgumentException("The color selected is not a valid color.");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts <see cref="TodoistColor"/> to <see cref="string"/>.
        /// </summary>
        /// <param name="todoistColor">
        /// The todoist color.
        /// </param>
        /// <returns>
        /// <see cref="TodoistColor"/> in <see cref="string"/>.
        /// </returns>
        /// <exception cref="InvalidEnumArgumentException">Throws <see cref="InvalidEnumArgumentException"/> 
        /// if the parameter is not a valid color.</exception>
        private static string ConvertTodoistColorToString(TodoistColor todoistColor)
        {
            switch (todoistColor)
            {
                case TodoistColor.Green:
                    return "bde876";
                case TodoistColor.Red:
                    return "ff8581";
                case TodoistColor.Orange:
                    return "ffc472";
                case TodoistColor.Yellow:
                    return "faed75";
                case TodoistColor.Blue:
                    return "a8c9e5";
                case TodoistColor.MediumGrey:
                    return "999999";
                case TodoistColor.Pink:
                    return "e3a8e5";
                case TodoistColor.LightGrey:
                    return "dddddd";
                case TodoistColor.Flame:
                    return "fc603c";
                case TodoistColor.Gold:
                    return "ffcc00";
                case TodoistColor.LightOpal:
                    return "74e8d4";
                case TodoistColor.BrilliantCerulean:
                    return "3cd6fc";
            }

            throw new InvalidEnumArgumentException("The color selected is not a valid color.");
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Color"/> class.
 /// </summary>
 /// <param name="todoistColor">
 /// The <see cref="TodoistColor"/>.
 /// </param>
 public Color(TodoistColor todoistColor)
 {
     this.todoistColor = todoistColor;
     this.htmlColor = ConvertTodoistColorToString(TodoistColor);
     this.rgb = ConvertStringToColor(this.htmlColor);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Update an existing project.
        /// </summary>
        /// <param name="projectId">
        /// The id of the project that is to be updated.
        /// </param>
        /// <param name="name">
        /// New name.
        /// </param>
        /// <param name="color">
        /// New color.
        /// </param>
        /// <param name="indent">
        /// New indent level.
        /// </param>
        /// <param name="itemOrder">
        /// New way of sorting tasks.
        /// </param>
        /// <param name="isCollapsed">
        /// Toggle collapse.
        /// </param>
        /// <param name="isGroup">
        /// Toggle group.
        /// </param>
        public void UpdateProject(
            int projectId, 
            string name, 
            TodoistColor? color, 
            int? indent, 
            int? itemOrder, 
            bool? isCollapsed, 
            bool? isGroup)
        {
            this.CheckLoginStatus();

            // Validation
            TodoistColor? internalColor = color;
            if (color == null)
            {
                internalColor = this.GetProject(projectId).Color.TodoistColor;
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                Project projectToBeChanged = this.GetProject(projectId);
                name = projectToBeChanged.Name;
            }

            if (isGroup != null && isGroup == true)
            {
                name = string.Format("*{0}", name);
            }

            Uri uri = Core.ConstructUri(
                "updateProject?", 
                string.Format(
                    "&project_id={0}&token={1}&name={2}&color={3}&indent={4}&order={5}&collapsed={6}", 
                    projectId, 
                    this.ApiToken, 
                    name, 
                    internalColor.GetHashCode(), 
                    indent, 
                    itemOrder, 
                    Convert.ToInt32(isCollapsed)), 
                false);
            string jsonResponse = Core.GetJsonData(uri);

            if (jsonResponse == "\"ERROR_PROJECT_NOT_FOUND\"")
            {
                throw new ProjectException("Name cannot be null.");
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Color"/> class.
 /// </summary>
 /// <param name="todoistColor">
 /// The <see cref="TodoistColor"/>.
 /// </param>
 public Color(TodoistColor todoistColor)
 {
     _todoistColor = todoistColor;
     _htmlColor    = ConvertTodoistColorToString(TodoistColor);
     _rgb          = ConvertStringToColor(_htmlColor);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Color"/> class.
 /// </summary>
 /// <param name="todoistColor">
 /// The <see cref="TodoistColor"/>.
 /// </param>
 public Color(TodoistColor todoistColor)
 {
     this.todoistColor = todoistColor;
     this.htmlColor    = ConvertTodoistColorToString(TodoistColor);
     this.rgb          = ConvertStringToColor(this.htmlColor);
 }