ChatterService.Web.ChatterProxyService.CreateGroup C# (CSharp) Method

CreateGroup() public method

public CreateGroup ( Stream stream ) : CommonResult
stream Stream
return CommonResult
        public CommonResult CreateGroup(Stream stream)
        {
            try {
                ValidateSignature();
                NameValueCollection p = parseParameters(stream);

                if (string.IsNullOrEmpty(p["name"]))
                {
                    return new CommonResult() { Success = false, ErrorMessage = "Group name is required." };
                }

                if (string.IsNullOrEmpty(p["ownerId"]))
                {
                    return new CommonResult() { Success = false, ErrorMessage = "OwnerId is required." };
                }

                string nodeId = p["ownerId"];
                string descr = p["description"];
                if (string.IsNullOrEmpty(descr))
                {
                    descr = p["name"];
                }

                string employeeId = profilesService.GetEmployeeId(nodeId);

                ChatterSoapService soap = getChatterSoapService();
                string groupId = soap.CreateGroup(p["name"], descr, employeeId);

                string users = p["users"];
                if (!string.IsNullOrEmpty(users))
                {
                    string[] personList = users.Split(',');
                    List<string> employeeList = new List<string>();
                    foreach (string pId in personList)
                    {
                        try
                        {
                            string eId = profilesService.GetEmployeeId(pId);
                            employeeList.Add(eId);
                        }
                        catch (Exception ex)
                        {
                            //TODO: need to report it back to the server
                        }
                    }

                    if (employeeList.Count > 0)
                    {
                        soap.AddUsersToGroup(groupId, employeeList.ToArray<string>());
                    }
                }
                return new CommonResult() { Success = true, URL = url.Replace("/services", "/_ui/core/chatter/groups/GroupProfilePage?g=" + groupId) };
            }
            catch (Exception ex)
            {
                HandleError(ex, url);
                return new CommonResult() { Success = false, ErrorMessage = ex.Message };
            }
        }