private void AddGroupAndUsers()
{
SPWeb web = SPContext.Current.Web;
web.AllowUnsafeUpdates = true;
web.SiteGroups.Add("MyTestGroup", web.CurrentUser, web.CurrentUser, string.Empty);
SPGroup group = web.SiteGroups["MyTestGroup"];
SPRoleDefinition roleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Contributor);
SPRoleAssignment roleAssigment = new SPRoleAssignment(group);
roleAssigment.RoleDefinitionBindings.Add(roleDefinition);
web.RoleAssignments.Add(roleAssigment);
web.Update();
SPUser spUser = web.EnsureUser("server\\username");
group.Users.Add(spUser.LoginName, spUser.Email, spUser.Name, spUser.Notes);
web.AllowUnsafeUpdates = false;
}