コード例 #1
0
        public async Task <HttpResponseMessage> Get(int id)
        {
            var endpoint = $"/desk/v1/tickets/{id}.json";
            var jsonData = await Teamwork.GetData(endpoint);

            var ticketData = JsonConvert.DeserializeObject <TeamworkDeskTicket>(jsonData);

            var result = JsonConvert.SerializeObject(ticketData);

            var resp = new HttpResponseMessage
            {
                Content = new StringContent(result, Encoding.UTF8, "application/json")
            };

            return(resp);
        }
コード例 #2
0
        public async Task <HttpResponseMessage> Get(int id = 0, string status = "")
        {
            var endpoint = "";

            if (string.IsNullOrEmpty(status))
            {
                endpoint = $"/desk/v1/smartinboxes/21/tickets.json?sortBy=createdAt&sortDir=DESC&startRow=1&groupId={id}";
            }

            else if (status == "assigned")
            {
                endpoint = $"/desk/v1/inboxes/{id}/tickets/Active.json?notAssignedTo[]=-1&notAssignedTo[]=156275&pageSize=1000&sortBy=createdAt&sortDir=ASC&startRow=1";
            }

            else if (status == "search")
            {
                endpoint = $"desk/v1/tickets/search.json?search={id}";
            }

            else
            {
                endpoint = $"/desk/v1/inboxes/{id}/tickets/{status}.json?pageSize=3000&sortBy=createdAt&sortDir=ASC&startRow=1";
            }


            var jsonData = await Teamwork.GetData(endpoint);

            var ticketData = JsonConvert.DeserializeObject <TeamworkDeskTickets>(jsonData);

            var result = JsonConvert.SerializeObject(ticketData);

            var resp = new HttpResponseMessage
            {
                Content = new StringContent(result, Encoding.UTF8, "application/json"),
            };

            return(resp);
        }
        // 05. Teamwork Projecct
        public static void TeamworkProject()
        {
            int n = int.Parse(Console.ReadLine());

            var teamList = new List <Teamwork>();

            Teamwork teamContainsFiltes           = null;
            Teamwork creatorOrMemberContainFilter = null;

            for (int i = 0; i < n; i++)
            {
                var    input    = Console.ReadLine().Split("-");
                string creator  = input[0];
                string teamName = input[1];

                teamContainsFiltes           = teamList.Find(x => x.Name == teamName);
                creatorOrMemberContainFilter = teamList.Find(x => x.Creator == creator);

                if (teamContainsFiltes != null)
                {
                    Console.WriteLine($"Team {teamName} was already created!");
                }
                else if (creatorOrMemberContainFilter != null)
                {
                    Console.WriteLine($"{creator} cannot create another team!");
                }
                else
                {
                    Teamwork newTeam = new Teamwork(creator, teamName);
                    teamList.Add(newTeam);

                    Console.WriteLine($"Team {teamName} has been created by {creator}!");
                }
            }

            string command;

            while ((command = Console.ReadLine()) != "end of assignment")
            {
                string[] splitedCommand = command.Split("->");
                string   member         = splitedCommand[0];
                string   team           = splitedCommand[1];

                teamContainsFiltes           = teamList.Find(x => x.Name == team);
                creatorOrMemberContainFilter = teamList.Find(x => x.Members.Contains(member));
                if (teamContainsFiltes == null)
                {
                    Console.WriteLine($"Team {team} does not exist!");
                }
                else if (creatorOrMemberContainFilter != null || teamContainsFiltes.Creator.Contains(member) || teamContainsFiltes.Members.Contains(member))
                {
                    Console.WriteLine($"Member {member} cannot join team {team}!");
                }
                else
                {
                    teamContainsFiltes.Members.Add(member);
                }
            }

            var filtered = teamList.Where(x => x.Members.Count > 0)
                           .OrderByDescending(x => x.Members.Count)
                           .ThenBy(x => x.Name).ToList();

            var disband = teamList.Where(x => x.Members.Count == 0)
                          .OrderBy(x => x.Name).ToList();

            foreach (var item in filtered)
            {
                Console.WriteLine(item.ToString());
            }

            Console.WriteLine("Teams to disband:");
            foreach (var item in disband)
            {
                Console.WriteLine(item.Name);
            }
        }