Exemplo n.º 1
0
        /// <summary>
        /// Will retreive all the Members for a specific key in the system
        /// </summary>
        /// <param name="key">Key for the Members that are being retrieved</param>
        /// <returns>MemberResult with all of the Members of a specific key, status of 200 if successfull, 500 for any other error</returns>
        public Models.MembersResult GetMembers(string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return new Models.MembersResult
                       {
                           StatusCode = 500,
                           Message    = "Invalid Argument"
                       }
            }
            ;

            if (!_items.ContainsKey(key))
            {
                return new Models.MembersResult
                       {
                           StatusCode = 500,
                           Message    = "Key doesnt exist"
                       }
            }
            ;

            Models.MembersResult membersResult = new Models.MembersResult
            {
                StatusCode = 200,
                Members    = new List <string>()
            };

            foreach (var member in _items[key])
            {
                membersResult.Members.Add(member);
            }

            return(membersResult);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Will retrieve all Members for all Keys
        /// </summary>
        /// <returns>MemberResult with all of the Members of every key, status of 200 if successfull, 500 for any other error</returns>
        public Models.MembersResult AllMembers()
        {
            Models.MembersResult membersResult = new Models.MembersResult
            {
                StatusCode = 200,
                Members    = new List <string>()
            };

            foreach (var item in _items)
            {
                foreach (var value in item.Value)
                {
                    membersResult.Members.Add(value);
                }
            }

            return(membersResult);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Will retrieve all Keys and the Members for each of those keys
        /// </summary>
        /// <returns>MemberResult with all of the keys and members for each of those keys, status of 200 if successfull, 500 for any other error</returns>
        public Models.MembersResult Items()
        {
            Models.MembersResult membersResult = new Models.MembersResult
            {
                StatusCode = 200,
                Members    = new List <string>()
            };

            int count = 1;

            foreach (var item in _items)
            {
                foreach (var value in item.Value)
                {
                    membersResult.Members.Add($"{ count}) {item.Key}: {value}");
                    count++;
                }
            }

            return(membersResult);
        }