Exemplo n.º 1
0
        public async Task <IEnumerable <TeamDetails> > GetTeamDetailsByCountryAsync(string teamName, string nameCountry)
        {
            var connStr = DbConnection.connectionString;
            var cmdStr  = "select * from team_details where team_name=@name and country=@country";
            List <TeamDetails> teams = new List <TeamDetails>();

            using (var conn = new NpgsqlConnection(connStr)) {
                using (var cmd = new NpgsqlCommand(cmdStr, conn)) {
                    cmd.Parameters.AddWithValue("@name", teamName);
                    cmd.Parameters.AddWithValue("@country", nameCountry);
                    await conn.OpenAsync();

                    using (NpgsqlDataReader rd = await cmd.ExecuteReaderAsync()) {
                        while (rd.Read())
                        {
                            var team = new TeamDetails();
                            team.PlayerID     = Convert.ToInt32(rd["player_id"]);
                            team.TeamName     = rd["team_name"].ToString();
                            team.TeamImage    = rd["team_image"].ToString();
                            team.FirstName    = rd["first_name"].ToString();
                            team.LastName     = rd["last_name"].ToString();
                            team.Position     = rd["position"].ToString();
                            team.CountryImage = rd["country_image"].ToString();
                            team.Country      = rd["country"].ToString();
                            teams.Add(team);
                        }
                    }
                }
            }
            return(teams);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Index(int teamId = 0)
        {
            try
            {
                if (teamId <= 0)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                TeamDetails td = new TeamDetails();

                var players = await CacheUtil.GetObjectFromCache("AllPlayersList", 60,
                                                                 RequestsUtil.GetPlayers);

                td.playersList = players.Where(x => x.Value.Team != null && x.Value.Team.Id == teamId)
                                 .OrderByDescending(y => y.Value.Height_inches + y.Value.Height_feet)
                                 .ToDictionary(v => v.Key, v => v.Value);

                td.team = await CacheUtil.GetObjectFromCache($"Team_{teamId}", 60,
                                                             () => RequestsUtil.GetTeam(teamId));

                return(View(td));
            }
            catch (Exception)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
Exemplo n.º 3
0
    public void UpdateTeamWithNewRecord(int teamId, string newDetailsSerialized)
    {
        TeamDetails newRecord = JsonUtility.FromJson <TeamDetails>(newDetailsSerialized);
        bool        found     = false;
        TeamDetails oldRecord = schema.teamsList[0];

        foreach (TeamDetails record in schema.teamsList)
        {
            if (record.teamId.Equals(teamId))
            {
                found     = true;
                oldRecord = record;
            }
        }
        if (found)
        {
            schema.teamsList.Remove(oldRecord);
            schema.teamsList.Add(newRecord);
        }
        if (scoreboard != null)
        {
            scoreboard.UpdateScores();
        }
        ForceSynchronisePlayerSchema();
    }
        public IEnumerable <TeamDetails> GetAllTeam()
        {
            using (FintellixPremierLeagueEntities FplDbEntities = new FintellixPremierLeagueEntities())
            {
                var data                    = FplDbEntities.getAllTeamDetails().ToList();
                var groupedTeams            = data.GroupBy(m => m.TeamID).Select(m => new { TeamID = m.Key, PlayersInTeam = m.ToList(), TeamName = m.FirstOrDefault().TeamName, OwnerName = m.FirstOrDefault().OwnerName, CaptainID = m.FirstOrDefault().CaptainID, CaptainName = m.FirstOrDefault().CaptainName });
                List <TeamDetails> allTeams = new List <TeamDetails>();
                foreach (var team in groupedTeams)
                {
                    TeamDetails teamData = new TeamDetails();
                    teamData.PlayersInTeam = new List <PlayerInfo>();
                    teamData.TeamID        = team.TeamID;
                    teamData.TeamName      = team.TeamName;
                    teamData.OwnerName     = team.OwnerName;
                    teamData.CaptainID     = team.CaptainID;
                    teamData.CaptainName   = team.CaptainName;

                    foreach (var player in team.PlayersInTeam)
                    {
                        PlayerInfo playerDetails = new PlayerInfo();
                        playerDetails.PlayerID   = player.PlayerID;
                        playerDetails.PlayerName = player.PlayerName;
                        teamData.PlayersInTeam.Add(playerDetails);
                    }
                    allTeams.Add(teamData);
                }
                return(allTeams);
            }
        }
        protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity)
        {
            try {
                TeamDetails teamDetails = (TeamDetails)entity;

                switch (xmlNode.Name)
                {
                case Tags.User:
                    if (xmlNode.ChildNodes != null)
                    {
                        teamDetails.userField = ParseUserNode(xmlNode);
                    }
                    break;

                case Tags.Team:
                    if (xmlNode.ChildNodes != null)
                    {
                        teamDetails.teamField = ParseTeamNode(xmlNode);
                    }
                    break;
                }
            } catch (Exception ex) {
                throw ex;
            }
        }
        }//View Team Details

        public SaveResponses SaveTeamMembers(TeamDetails teamDetails)
        {
            SaveResponses saveResponses = new SaveResponses();
            DAL_Team      team          = new DAL_Team();

            try
            {
                if (teamDetails.MemberList.Count > 0)
                {
                    bool saveSuccess = team.SaveTeamMembers(teamDetails);
                    if (saveSuccess)
                    {
                        saveResponses.saveStatus  = "true";
                        saveResponses.messageType = "success";
                    }
                    else
                    {
                        saveResponses.saveStatus  = "false";
                        saveResponses.messageType = "error";
                    }
                }
                else
                {
                    saveResponses.saveStatus  = "false";
                    saveResponses.messageType = "error";
                }
                return(saveResponses);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult TeamDetails(int id)
        {
            TeamDetails team = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://localhost:44337/api/");
                //HTTP GET BY ID
                var responseTask = client.GetAsync($"Team/{id}");
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <TeamDetails>();
                    readTask.Wait();

                    team = readTask.Result;
                }
                else
                {
                    team = new TeamDetails();

                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                }
            }
            return(View(team));
        }
        public List <TeamDetails> GetTeam(int id)
        {
            using (FintellixPremierLeagueEntities FplDbEntities = new FintellixPremierLeagueEntities())
            {
                var data                    = FplDbEntities.getTeamDetailsByTeamID(id).ToList();
                var groupedTeam             = data.GroupBy(m => m.TeamID).Select(m => new { TeamID = m.Key, PlayersInTeam = m.ToList(), TeamName = m.FirstOrDefault().TeamName, OwnerName = m.FirstOrDefault().OwnerName, CaptainID = m.FirstOrDefault().CaptainID, CaptainName = m.FirstOrDefault().CaptainName });
                List <TeamDetails> allTeams = new List <TeamDetails>();
                foreach (var team in groupedTeam)
                {
                    TeamDetails teamData = new TeamDetails();
                    teamData.PlayersInTeam = new List <PlayerInfo>();
                    teamData.TeamID        = team.TeamID;
                    teamData.TeamName      = team.TeamName;
                    teamData.OwnerName     = team.OwnerName;
                    teamData.CaptainID     = team.CaptainID;
                    teamData.CaptainName   = team.CaptainName;

                    foreach (var player in team.PlayersInTeam)
                    {
                        PlayerInfo playerDetails = new PlayerInfo();
                        playerDetails.PlayerID       = player.PlayerID;
                        playerDetails.PlayerName     = player.PlayerName;
                        playerDetails.BattingStyle   = player.BattingStyle;
                        playerDetails.BowlingStyle   = player.BowlingStyle;
                        playerDetails.Bio            = player.Bio;
                        playerDetails.AuctionedPrice = player.AuctionedPrice ?? default(int);
                        teamData.PlayersInTeam.Add(playerDetails);
                    }
                    allTeams.Add(teamData);
                }
                return(allTeams);
            }
        }
 public ArenaDetails()
 {
     Team            = new TeamDetails();
     League          = new LeagueDetails();
     Region          = new RegionDetails();
     CurrentCapacity = new CurrentCapacityDetails();
 }
Exemplo n.º 10
0
        /// <summary>
        /// DropDownForClient
        /// Calls [usp_dropdown_Team_for_Client]
        /// </summary>
        public override List <TeamDetails> DropDownForClient(System.Int32?clientId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_dropdown_Team_for_Client", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
                cn.Open();
                DbDataReader       reader = ExecuteReader(cmd);
                List <TeamDetails> lst    = new List <TeamDetails>();
                while (reader.Read())
                {
                    TeamDetails obj = new TeamDetails();
                    obj.TeamId   = GetReaderValue_Int32(reader, "TeamId", 0);
                    obj.TeamName = GetReaderValue_String(reader, "TeamName", "");
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Teams", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Exemplo n.º 11
0
        public async Task <IEnumerable <TeamDetails> > GetTeamByName_withSearchAsync(string name, string search)
        {
            var connStr = DbConnection.connectionString;
            var cmdStr  = "Select * from getteambynamewithsearch(@name,@search);";
            List <TeamDetails> teams = null;

            using (var conn = new NpgsqlConnection(connStr)) {
                using (var cmd = new NpgsqlCommand(cmdStr, conn)) {
                    cmd.Parameters.AddWithValue("@name", name);
                    cmd.Parameters.AddWithValue("@search", search);
                    await conn.OpenAsync();

                    using (NpgsqlDataReader rd = await cmd.ExecuteReaderAsync()) {
                        while (rd.Read())
                        {
                            var team = new TeamDetails();
                            team.TeamName     = rd["TeamName"].ToString();
                            team.TeamImage    = rd["TeamImage"].ToString();
                            team.FirstName    = rd["FirstName"].ToString();
                            team.LastName     = rd["LastName"].ToString();
                            team.Position     = rd["position"].ToString();
                            team.CountryImage = rd["CountryImage"].ToString();
                            teams.Add(team);
                        }
                    }
                }
            }
            return(teams);
        }
        public async Task StartAsync(IDialogContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var team = context.Activity.GetChannelData <TeamsChannelData>().Team;

            if (team != null)
            {
                var connectorClient = new ConnectorClient(new Uri(context.Activity.ServiceUrl));

                // Handle for channel conversation, AAD GroupId only exists within channel
                TeamDetails teamDetails = await connectorClient.GetTeamsConnectorClient().Teams.FetchTeamDetailsAsync(team.Id);

                var message = context.MakeMessage();
                message.Text = GenerateTable(teamDetails);

                await context.PostAsync(message);
            }
            else
            {
                // Handle for 1 to 1 bot conversation
                await context.PostAsync(Strings.TeamInfo1To1ConversationError);
            }

            //Set the Last Dialog in Conversation Data
            context.UserData.SetValue(Strings.LastDialogKey, Strings.LastDialogFetchTeamInfoDialog);

            context.Done <object>(null);
        }
        public void TeamDetailsInitsWithNoArgs()
        {
            var teamDetails = new TeamDetails();

            Assert.NotNull(teamDetails);
            Assert.IsType <TeamDetails>(teamDetails);
        }
        public async Task TeamsAPI_FetchTeamDetailsAsync()
        {
            Microsoft.Rest.ServiceClientTracing.IsEnabled = true;
            TeamDetails teamDetails = new TeamDetails
            {
                Id         = "TeamId",
                AadGroupId = "GroupId",
                Name       = "TeamName",
            };

            TestDelegatingHandler testHandler = new TestDelegatingHandler((request) =>
            {
                StringContent stringContent = new StringContent(JsonConvert.SerializeObject(teamDetails));
                var response     = new HttpResponseMessage(HttpStatusCode.OK);
                response.Content = stringContent;
                return(Task.FromResult(response));
            });

            TeamsConnectorClient teamsConnectorClient = new TeamsConnectorClient(
                new Uri("https://smba.trafficmanager.net/amer-client-ss.msg/"),
                new MicrosoftAppCredentials("Test", "Test"),
                testHandler);

            TeamDetails teamDetailsResult = await teamsConnectorClient.Teams.FetchTeamDetailsAsync("TestTeamId").ConfigureAwait(false);

            Assert.IsNotNull(teamDetailsResult);
            Assert.IsNotNull(teamDetailsResult.Id);
            Assert.IsNotNull(teamDetailsResult.Name);
            Assert.IsNotNull(teamDetailsResult.AadGroupId);
            Assert.AreEqual(teamDetailsResult.Id, teamDetails.Id);
            Assert.AreEqual(teamDetailsResult.Name, teamDetails.Name);
            Assert.AreEqual(teamDetailsResult.AadGroupId, teamDetails.AadGroupId);
        }
        private TeamDetails LoadTeamMember(int teamId)
        {
            TeamDetails model    = null;
            HttpClient  client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var         response = client.GetAsync("api/Team/GetById/" + teamId).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                model = JsonConvert.DeserializeObject <TeamDetails>(jsonData);
                var SelectedTeam = new Team();
                SelectedTeam.AdminId     = model.Team.AdminId;
                SelectedTeam.Id          = model.Team.Id;
                SelectedTeam.Name        = model.Team.Name;
                SelectedTeam.TeamMembers = model.AcceptedUsers;
                LicenseSessionState.Instance.SelectedTeam = SelectedTeam;
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
            }
            return(model);
        }
Exemplo n.º 16
0
        public ActionResult RevokeTeamLicense(int teamId)
        {
            TeamDetails teamDetails = new TeamDetails();

            teamDetails.Team        = LicenseSessionState.Instance.TeamList.ToList().Where(t => t.Id == teamId).FirstOrDefault();
            teamDetails.ProductList = OnPremiseSubscriptionLogic.GetTeamLicenseDetails(teamId);
            return(View(teamDetails));
        }
 /// <summary>
 /// Supprime les droits de la team sur la liste de projets
 /// </summary>
 /// <param name="iGroup"></param>
 /// <param name="iTeam"></param>
 /// <param name="iForbidenProjectList"></param>
 public static void RemoveProjectPermissionsToTeam(this Group iGroup, TeamDetails iTeam, List <Guid> iForbidenProjectList)
 {
     //Bouclage sur les projets à enlever les droits
     foreach (var projectItem in iForbidenProjectList.Enum())
     {
         iGroup.Security.TryRemoveProjectPermissionFromTeam(iTeam.Id, projectItem, StandardProjectPermissions.EditPermission);
     }
 }
Exemplo n.º 18
0
        public JsonResult IterationsList(string ORG, string project)
        {
            TeamDetails             teams          = new TeamDetails();
            List <IterationDetails> iterationsList = new List <IterationDetails>();
            string responseBody = "";

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    client.DefaultRequestHeaders.Accept.Add(
                        new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(
                                                                                                   System.Text.ASCIIEncoding.ASCII.GetBytes(
                                                                                                       string.Format("{0}:{1}", "", Session["PAT"] == null ? Request.QueryString["code"] : Session["PAT"].ToString()))));

                    using (HttpResponseMessage response = client.GetAsync("https://dev.azure.com/" + ORG + "/_apis/projects/" + project + "/teams?api-version=5.1").Result)
                    {
                        response.EnsureSuccessStatusCode();
                        responseBody = response.Content.ReadAsStringAsync().Result;
                        teams        = JsonConvert.DeserializeObject <TeamDetails>(responseBody);
                    }
                }
                if (teams.value != null && teams.value.Count > 0)
                {
                    foreach (var team in teams.value)
                    {
                        IterationDetails iterationDetails = new IterationDetails();
                        string           teamname         = team.name;
                        using (HttpClient client = new HttpClient())
                        {
                            client.DefaultRequestHeaders.Accept.Add(
                                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(
                                                                                                           System.Text.ASCIIEncoding.ASCII.GetBytes(
                                                                                                               string.Format("{0}:{1}", "", Session["PAT"] == null ? Request.QueryString["code"] : Session["PAT"].ToString()))));
                            string url = "https://dev.azure.com/" + ORG + "/" + project + "/" + teamname + "/_apis/work/teamsettings/iterations?api-version=5.1";
                            using (HttpResponseMessage response = client.GetAsync(url).Result)
                            {
                                response.EnsureSuccessStatusCode();
                                responseBody              = response.Content.ReadAsStringAsync().Result;
                                iterationDetails          = JsonConvert.DeserializeObject <IterationDetails>(responseBody);
                                iterationDetails.teamname = teamname;
                                iterationsList.Add(iterationDetails);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(""));
            }
            Session["iterationsList"] = iterationsList;
            return(Json(iterationsList, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 19
0
        private async Task <IReportBodyDetails> GetReportBodyDetailsAsync(ITurnContext context, IEnumerable <IMessageDetails> messages, ReportParameters parameters, CancellationToken cancellationToken)
        {
            var details = new ReportBodyDetails()
            {
                IsChannel      = parameters.ReportType == ReportSourceType.Channel,
                IsConversation = parameters.ReportType == ReportSourceType.Conversation,
                IsGroupChat    = parameters.ReportType == ReportSourceType.Chat,
                Messages       = messages,
                Since          = parameters.Since,
                Till           = parameters.Till,
                Author         = context.Activity.From?.Name,
            };

            if (context.Activity.Conversation.ConversationType == Constants.ChannelConversationType)
            {
                var channelData = context.Activity.GetChannelData <TeamsChannelData>();
                var teamDetails = new TeamDetails(channelData.Team.Id, channelData.Team.Name);
                details.ChannelName = channelData.Channel.Name;
                if (channelData.Team.Id == channelData.Channel.Id)
                {
                    // The channel ID for the General channel always matches the team ID (from MS documentation).
                    // The name of the default General channel is returned as null to allow for localization. (from MS documentation).
                    details.ChannelName = Resources.Strings.TeamGeneralChannelDefaultTitle;
                }

                try
                {
                    teamDetails = await TeamsInfo.GetTeamDetailsAsync(context, channelData.Team.Id, cancellationToken);

                    if (teamDetails != null)
                    {
                        details.TeamName = teamDetails.Name;
                        details.TeamId   = teamDetails.AadGroupId;
                        if (string.IsNullOrEmpty(details.ChannelName))
                        {
                            var channels = await TeamsInfo.GetTeamChannelsAsync(context, channelData.Team.Id, cancellationToken);

                            details.ChannelName = channels?.FirstOrDefault(x => channelData.Channel.Id.Equals(x.Id))?.Name;
                        }
                    }
                }
                catch
                {
                    // Bot is not aaded to the team, Forbidden exception here
                    details.TeamName = channelData.Team.Id; // Team name is not available here
                    details.TeamId   = channelData.Team.Id;
                    logger.LogWarning($"Bot is not added to team {channelData.Team.Id}");
                }

                if (string.IsNullOrEmpty(details.ChannelName))
                {
                    // Fill it with channel id if name is not available.
                    details.ChannelName = channelData.Channel.Id;
                }
            }

            return(details);
        }
Exemplo n.º 20
0
        //"https://dev.azure.com/" + ORG + "/_apis/projects/" + project + "/teams?api-version=5.1"
        //  public JsonResult IterationsList(string ORG, string project)
        public List <IterationDetails> IterationsList(string ORG, string project)
        {
            TeamDetails             teams          = new TeamDetails();
            List <IterationDetails> iterationsList = new List <IterationDetails>();
            string responseBody = "";
            string api          = string.Format("https://dev.azure.com/{0}/_apis/projects/{1}/teams?api-version=5.1", Org.OrganizationName, project);

            try
            {
                using (var client = new HttpClient())
                {
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Org.pat);//Org.pat);
                    HttpResponseMessage response = client.GetAsync(api).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        var obj = response.Content.ReadAsStringAsync().Result;
                        teams = JsonConvert.DeserializeObject <TeamDetails>(obj);
                    }
                }

                if (teams.value != null && teams.value.Count > 0)
                {
                    foreach (var team in teams.value)
                    {
                        IterationDetails iterationDetails = new IterationDetails();
                        string           teamname         = team.name;
                        string           url = "https://dev.azure.com/" + ORG + "/" + project + "/" + teamname + "/_apis/work/teamsettings/iterations?api-version=5.1";
                        using (var client = new HttpClient())
                        {
                            client.DefaultRequestHeaders.Accept.Clear();
                            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Org.pat);//Org.pat);
                            HttpResponseMessage response = client.GetAsync(url).Result;

                            if (response.IsSuccessStatusCode)
                            {
                                var obj = response.Content.ReadAsStringAsync().Result;
                                iterationDetails          = JsonConvert.DeserializeObject <IterationDetails>(obj);
                                iterationDetails.teamname = teamname;
                                iterationsList.Add(iterationDetails);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //  return Json("");
                return(iterationsList);
            }
            Session["iterationsList"] = iterationsList;
            //return Json(iterationsList, JsonRequestBehavior.AllowGet);
            return(iterationsList);
        }
        private void ViewTeam(object sender, RoutedEventArgs e)
        {
            var selection = grdTeams.SelectedItem as Team;

            if (selection != null)
            {
                var detailView = new TeamDetails();
                detailView.Initialize(selection.ID);
                MainWindow.LoadView(detailView);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Get the name of a team.
        /// </summary>
        /// <param name="botAdapter">Bot adapter.</param>
        /// <param name="teamInfo">DB team model info.</param>
        /// <returns>The name of the team</returns>
        public virtual async Task <string> GetTeamNameByIdAsync(BotAdapter botAdapter, TeamInstallInfo teamInfo)
        {
            TeamDetails teamDetails = null;

            await this.ExecuteInNewTurnContext(botAdapter, teamInfo, async (newTurnContext, newCancellationToken) =>
            {
                teamDetails = await this.GetTeamDetailsAsync(newTurnContext, teamInfo.TeamId, newCancellationToken);
            });

            return(teamDetails?.Name);
        }
 /// <summary>
 /// Affecte les droits à la liste des projects en argument
 /// </summary>
 /// <param name="iGroup"></param>
 /// <param name="iTeam"></param>
 /// <param name="iAllowedProjectList"></param>
 public static void AddPermissionToTeam(this Group iGroup, TeamDetails iTeam, List <Guid> iAllowedProjectList)
 {
     //Bouclage sur les projets à autoriser
     foreach (var item in iAllowedProjectList.Enum())
     {
         if (!iGroup.Security.TryAddProjectPermissionToTeam(iTeam.Id, item, StandardProjectPermissions.EditPermission))
         {
             throw new Exception("Erreur lors de l'ajout du droit d'édition");
         }
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// Populates the details of the team selected
        /// </summary>
        /// <param name="teamSelected">The team selected</param>
        /// <returns>Details of the team</returns>
        public TeamDetails[] PopulateTeamPlayers(int teamSelected)
        {
            Team teamName = new Team();

            TeamDetails[] team = new TeamDetails[11];

            team = this.GenerateTeamStatus(team);

            team = this.PopulatePlayers(teamSelected, team);

            return(team);
        }
        /// <summary>
        /// Handles the new member added action.
        /// </summary>
        /// <param name="activity">activity object.</param>
        /// <returns>Task.</returns>
        private async Task HandleMemberAddedActionAsync(Activity activity)
        {
            this.logProvider.LogInfo("Performing member added action.");

            bool isBotAdded  = activity.MembersAdded.Any(member => member.Id == activity.Recipient.Id);
            var  channelData = activity.GetChannelData <TeamsChannelData>();

            this.serviceUrl = activity.ServiceUrl;
            string teamId        = channelData?.Team?.Id;
            string installerName = activity.From?.Name;
            IList <ChannelAccount> teamMembers = null;
            bool        isBotInstalledInTeam   = teamId == null ? false : true;
            TeamDetails teamDetails            = null;

            if (string.IsNullOrWhiteSpace(installerName) && !string.IsNullOrWhiteSpace(teamId))
            {
                installerName = await this.GetUserNameAsync(teamId, activity.From);
            }

            if (!string.IsNullOrEmpty(teamId))
            {
                this.logProvider.LogInfo($"fetching team details using connector client for team Id:{teamId}.");
                teamDetails = await this.connectorClient.GetTeamsConnectorClient().Teams.FetchTeamDetailsAsync(teamId);
            }

            if (isBotAdded)
            {
                this.LogBotInstallationInformation(teamId, installerName, isBotInstalledInTeam);

                if (!string.IsNullOrWhiteSpace(teamId))
                {
                    // Add Team details,where the bot is installed.
                    await this.AddTeamDetailsAsync(teamId, teamDetails.Name);

                    teamMembers = await this.connectorClient.Conversations.GetConversationMembersAsync(teamId);
                }

                // Send welcome message in General Channel
                await this.SendWelcomeMessageToGeneralChannel(activity, isBotInstalledInTeam, installerName, teamDetails.Name);
            }
            else
            {
                teamMembers = activity.MembersAdded;
            }

            if (teamMembers != null && teamMembers.Count > 0)
            {
                // Send Welcome message to all the team members.
                await this.SendWelcomeMessageToTeamMembers(teamMembers, channelData, installerName, teamDetails.Name);
            }

            this.logProvider.LogInfo("Completed member added action.");
        }
        /// <summary>
        /// Supprime tous les droits de la team et réaffecte les droits à la liste des projects en argument
        /// </summary>
        /// <param name="iGroup"></param>
        /// <param name="iTeam"></param>
        /// <param name="iAllowedProjectList"></param>
        public static void SetExclusitivelyPermissionToTeam(this Group iGroup, TeamDetails iTeam, List <Guid> iAllowedProjectList)
        {
            var completeProjectList = iGroup.Projects.GetProjects().Enum().Select(x => x.Id).Enum().ToList();

            RemoveProjectPermissionsToTeam(iGroup, iTeam, completeProjectList);

            //Bouclage sur les projets à autoriser
            foreach (var item in iAllowedProjectList.Enum())
            {
                iGroup.Security.TryAddProjectPermissionToTeam(iTeam.Id, item, StandardProjectPermissions.EditPermission);
            }
        }
Exemplo n.º 27
0
 public bool UpdateTeam(TeamDetails model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .Teams
             .Single(e => e.TeamId == model.TeamId);
         entity.Name = model.Name;
         return(ctx.SaveChanges() == 1);
     }
 }
Exemplo n.º 28
0
        public HttpResponseMessage GetTeamById(int id)
        {
            TeamDetails dtls = teamBoLogic.GetteamDetails(id);

            if (dtls != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, dtls));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, teamBoLogic.ErrorMessage));
            }
        }
Exemplo n.º 29
0
        private static Team PopulateFromDBDetailsObject(TeamDetails obj)
        {
            Team objNew = new Team();

            objNew.TeamId          = obj.TeamId;
            objNew.ClientNo        = obj.ClientNo;
            objNew.TeamName        = obj.TeamName;
            objNew.Notes           = obj.Notes;
            objNew.UpdatedBy       = obj.UpdatedBy;
            objNew.DLUP            = obj.DLUP;
            objNew.NumberOfMembers = obj.NumberOfMembers;
            return(objNew);
        }
Exemplo n.º 30
0
 private void UpdateTeam(ref int teamId, DateTime?startDate, DateTime?endDate)
 {
     //ugly hack ahead
     if (startDate == null || endDate == null)
     { // get data from CHPP
         TeamDetails td = Environment.DataBridgeFactory.TeamDetailsBridge.GetTeamDetails((uint)teamId);
         matchFilterControl.Prepare(td.ID, td.Owner.JoinDate.Value, DateTime.Now.ToHtTime(), _translator);
         teamId = td.ID;
     }
     else
     { // use date specified by user input
         matchFilterControl.Prepare(teamId, startDate.Value, endDate.Value, _translator);
     }
 }