Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Member,Team")] TeamMembers teamMembers)
        {
            if (id != teamMembers.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teamMembers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeamMembersExists(teamMembers.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Member"] = new SelectList(_context.Members, "Id", "MemberEmail", teamMembers.Member);
            ViewData["Team"]   = new SelectList(_context.Teams, "Id", "TeamDescription", teamMembers.Team);
            return(View(teamMembers));
        }
Beispiel #2
0
        public void CreateTeam()
        {
            TeamModel team = new TeamModel(TeamName);

            SqlDataHandler.CreateTeam(team);

            foreach (PlayerModel player in TeamMembers)
            {
                team.TeamMembers.Add(player);
                SqlDataHandler.CreateTeamMembers(team, player);
            }

            if (_tournamentCreationView != null)
            {
                var conductor = Parent as IConductor;
                _tournamentCreationView.TournamentTeams.Add(team);
                conductor.ActivateItem(_tournamentCreationView);
            }
            else
            {
                TeamName = "";
                TeamMembers.Clear();
                ErrorMessage = null;
            }
        }
        public async Task <ActionResult <TeamMembers> > PostTeamMembers(TeamMembers teamMembers)
        {
            _context.TeamMembers.Add(teamMembers);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTeamMembers", new { id = teamMembers.Id }, teamMembers));
        }
Beispiel #4
0
        public override int GetHashCode()
        {
            int hashCode = -682174453;

            if (Context != null)
            {
                hashCode += Context.GetHashCode();
            }

            if (TeamMembers != null)
            {
                hashCode += TeamMembers.GetHashCode();
            }

            if (Cursor != null)
            {
                hashCode += Cursor.GetHashCode();
            }

            if (Errors != null)
            {
                hashCode += Errors.GetHashCode();
            }

            return(hashCode);
        }
Beispiel #5
0
        /// <summary>
        /// Retrieve team members in a team
        /// </summary>
        /// <param name="token">User access token</param>
        /// <returns>Team members</returns>
        public async Task <TeamMembers> GetTeamMembers()
        {
            _telemetry.TrackEvent("GetTeamMembers");
            _accessToken = await AuthenticationHelper.GetAccessTokenAsync(_configuration, _httpClientFactory, _telemetry);

            string      endpoint    = $"{_configuration["GroupsEndPoint"]}{_configuration["TeamId"]}/members?$top={_configuration["TeamMembersCount"]}";
            TeamMembers teamMembers = null;
            HttpClient  client      = _httpClientFactory.CreateClient("GraphWebClient");

            using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, endpoint))
            {
                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken);
                using (HttpResponseMessage response = await client.SendAsync(request))
                {
                    if (response.IsSuccessStatusCode)
                    {
                        string groupMembers = await response.Content.ReadAsStringAsync();

                        try
                        {
                            teamMembers = JsonConvert.DeserializeObject <TeamMembers>(groupMembers);
                        }
                        catch (Exception ex)
                        {
                            _telemetry.TrackException(ex);
                        }
                    }
                }
            }

            return(teamMembers);
        }
Beispiel #6
0
        public List <List <FinancialExpandedResults> > getSelectedFinancialResults(int year, int quarter, int accountId)
        {
            List <List <FinancialExpandedResults> > returnList = new List <List <FinancialExpandedResults> >();
            List <int> reportedEmpIds = getTimeReportedEmpIdForQuarter(year, quarter, accountId);

            if (reportedEmpIds.Count != 0)
            {
                if (authRepo.getAdminRights() || authRepo.getTeamLeadRights(accountId))
                {
                    foreach (int empId in reportedEmpIds)
                    {
                        string query = "SELECT [Id],[EmpId],[EmpName],[AccountId],[AccountName],[Year],[Month],[Quarter],[BillableType],[AllocatedHours],[BillableHours],[TotalReportedHours],[ConsiderableHours],[ExtraOrLag] FROM [FinancialResults] WHERE Year='" + year + "' and Quarter='" + quarter + "' and AccountId='" + accountId + "' and EmpId='" + empId + "' order by EmpId asc,Month asc";
                        if (year == 0 & quarter == 0)
                        {
                            query = "SELECT [Id],[EmpId],[EmpName],[AccountId],[AccountName],[Year],[Month],[Quarter],[BillableType],[AllocatedHours],[BillableHours],[TotalReportedHours],[ConsiderableHours],[ExtraOrLag] FROM [FinancialResults] WHERE Year=(select max(year) from FinancialResults where [AccountId ]=" + accountId + ") and Quarter=(select top(1) [Quarter ] from FinancialResults where [AccountId ]=" + accountId + " order by YEAR desc, [Quarter ] desc) and AccountId=" + accountId + " and EmpId='" + empId + "'  order by EmpId asc,Month asc";
                        }
                        Debug.WriteLine("Results " + query);
                        returnList.Add(this._db.Query <FinancialExpandedResults>(query).ToList());
                    }
                }
                else
                {
                    TeamMembers member = authRepo.getLoggedInUser();
                    string      query  = "SELECT [Id],[EmpId],[EmpName],[AccountId],[AccountName],[Year],[Month],[Quarter],[BillableType],[AllocatedHours],[BillableHours],[TotalReportedHours],[ConsiderableHours],[ExtraOrLag] FROM [FinancialResults] WHERE Year='" + year + "' and Quarter='" + quarter + "' and AccountId='" + accountId + "' and EmpId='" + member.Id + "' order by EmpId asc,Month asc";
                    if (year == 0 & quarter == 0)
                    {
                        query = "SELECT [Id],[EmpId],[EmpName],[AccountId],[AccountName],[Year],[Month],[Quarter],[BillableType],[AllocatedHours],[BillableHours],[TotalReportedHours],[ConsiderableHours],[ExtraOrLag] FROM [FinancialResults] WHERE Year=(select max(year) from FinancialResults where [AccountId ]=" + accountId + ") and Quarter=(select top(1) [Quarter ] from FinancialResults where [AccountId ]=" + accountId + " order by YEAR desc, [Quarter ] desc) and AccountId=" + accountId + " and EmpId='" + member.Id + "'  order by EmpId asc,Month asc";
                    }
                    Debug.WriteLine("Results " + query);
                    returnList.Add(this._db.Query <FinancialExpandedResults>(query).ToList());
                }
            }

            return(returnList);
        }
Beispiel #7
0
        public int addIfNotexists([FromBody] string accountData)
        {
            string[] accountArray = accountData.Split('~');
            foreach (string account in accountArray)
            {
                if (account != "undefined")
                {
                    Debug.WriteLine("Account " + account);
                    string      userName    = account.Split(':')[2];
                    string      accountName = account.Split(':')[1];
                    string      accountCode = account.Split(':')[0];
                    TeamMembers teamMember  = tmRepo.getSelectedEmployee(userName);
                    if (teamMember != null)
                    {
                        Account newAccount = new Account();
                        newAccount.AccCode      = accountCode;
                        newAccount.AccountName  = accountName;
                        newAccount.AccountOwner = teamMember.Id;
                        newAccount.Availability = true;

                        Account existingAccount = repo.Get(accountCode);
                        if (existingAccount == null)
                        {
                            repo.add(newAccount);
                        }
                    }
                }
            }
            return(0);
        }
        public async Task <ActionResult> Create([Bind(Include = "teamId,teamName,teamDesc,teamStartDate,teamLogo")] Team team,
                                                HttpPostedFileBase uploadImage)
        {
            if (ModelState.IsValid)
            {
                // Add in team member by team ID and UseID


                if (uploadImage != null)
                {
                    team.teamLogo = Guid.NewGuid() + Path.GetExtension(uploadImage.FileName);
                    uploadImage.SaveAs(Server.MapPath(Image_path + team.teamLogo));
                }

                // add logo and date
                db.Team.Add(team);
                await db.SaveChangesAsync();

                // team member
                var         userId = User.Identity.GetUserId();
                TeamMembers t      = new TeamMembers();
                t.teamId     = team.teamId;
                t.UserId     = userId;
                t.memberRole = "Admin";
                db.TeamMembers.Add(t);
                await db.SaveChangesAsync();

                return(RedirectToAction("index", "UserDashboard"));
            }

            return(View(team));
        }
Beispiel #9
0
        public async Task <ActionResult <List <TeamMemberDetails> > > TeamMemberDetailsAsync()
        {
            _telemetry.TrackEvent("TeamMemberDetailsAsync");
            try
            {
                List <TeamMemberDetails> teamMemberDetails = new List <TeamMemberDetails>();
                TeamMembers team = await _graph.GetTeamMembers();

                if (team != null)
                {
                    foreach (Member member in team.Value)
                    {
                        TeamMemberDetails teamMember = new TeamMemberDetails()
                        {
                            GivenName         = member.GivenName,
                            UserPrincipalName = member.UserPrincipalName,
                            JobTitle          = member.JobTitle,
                            ProfilePhotoUrl   = await _graph.GetPhoto(member.Id)
                        };
                        teamMemberDetails.Add(teamMember);
                    }
                }

                return(teamMemberDetails);
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
                return(null);
            }
        }
Beispiel #10
0
        public async Task <IActionResult> PutTeamMembers([FromRoute] int id, [FromBody] TeamMembers teamMembers)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != teamMembers.TeamMemberId)
            {
                return(BadRequest());
            }

            _context.Entry(teamMembers).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeamMembersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #11
0
        public async Task <TeamMembers> GetMyTeams(JWTToken jWT, int idGame)
        {
            Url_data            url_      = new Url_data();
            HttpResponseMessage response  = null;
            TeamMembers         ListTeams = null;
            var authValue = new AuthenticationHeaderValue("Bearer", jWT.Token);

            using (var client = new HttpClient()
            {
                DefaultRequestHeaders = { Authorization = authValue }
            })
            {
                try { response = await client.GetAsync(url_.TeamMembers_I.ToString() + "/" + idGame); }                // REST GET
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                    Debug.WriteLine(ex.Message.ToString());
                }
                if (response.IsSuccessStatusCode)                                             /// Status Code
                {
                    string responseContent = await response.Content.ReadAsStringAsync();      // Read GET

                    ListTeams = JsonConvert.DeserializeObject <TeamMembers>(responseContent); // Deserialize JSON
                }
                else
                {
                    return(null);
                }
                return(ListTeams);
            }
        }
Beispiel #12
0
        public async Task <IActionResult> OnGetAsync()
        {
            if (LoggedInUser == null)
            {
                return(Challenge());
            }

            TeamMembers playerTeam = await(from member in _context.TeamMembers
                                           where member.Member == LoggedInUser &&
                                           member.Team.Event == Event
                                           select member).FirstOrDefaultAsync();

            if (playerTeam != null)
            {
                return(RedirectToPage("./Details", new { teamId = playerTeam.Team.ID }));
            }

            var applications = from TeamApplication application in _context.TeamApplications
                               where application.Player == LoggedInUser && application.Team.Event == Event
                               select application.Team;

            AppliedTeam = await applications.FirstOrDefaultAsync();

            await LoadTeamDataAsync();

            return(Page());
        }
Beispiel #13
0
        public async Task <IActionResult> OnGetRemoveMemberAsync(int teamId, int teamMemberId)
        {
            if (EventRole == EventRole.play && !Event.IsTeamRegistrationActive)
            {
                return(NotFound("Membership changes are not open."));
            }

            TeamMembers member = await _context.TeamMembers.FirstOrDefaultAsync(m => m.ID == teamMemberId && m.Team.ID == teamId);

            if (member == null)
            {
                return(NotFound("Could not find team member with ID '" + teamMemberId + "'. They may have already been removed from the team."));
            }

            if (EventRole == EventRole.play)
            {
                int teamCount = await(from count in _context.TeamMembers
                                      where count.Team.ID == teamId
                                      select count).CountAsync();
                if (teamCount == 1)
                {
                    return(NotFound("Cannot remove the last member of a team. Delete the team instead."));
                }
            }

            _context.TeamMembers.Remove(member);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Details", new { teamId = teamId }));
        }
Beispiel #14
0
        private async void UpdateTeamMembers()
        {
            if (_loaded)
            {
                string teamId = _team?.TeamId;

                if (teamId != null)
                {
                    var list = await Logic.GetTeamMembers(_team, true);

                    if (teamId == _team.TeamId)
                    {
                        TeamMembers.Clear();
                        TeamMembers.Add(null);
                        list.ForEach(x => TeamMembers.Add(x));

                        var iterations = await Logic.GetTeamIterations(_team.TeamId);

                        if (teamId == _team.TeamId)
                        {
                            TeamIterations.Clear();
                            iterations.Values.OrderBy(x => x.StartDate).ToList().ForEach(x => TeamIterations.Add(x));
                        }
                    }
                }
            }
        }
Beispiel #15
0
        public ActionResult Create(HttpPostedFileBase file, TeamMembers teamMembers)
        {
            if (ModelState.IsValid)
            {
                if (file != null && file.ContentLength > 0)
                {
                    var fileName   = "";
                    var randomFile = "";
                    var uploadDir  = "~/Content/Images/TeamMembers";

                    System.IO.Directory.CreateDirectory(Server.MapPath(uploadDir));

                    fileName = file.FileName;
                    string extension = Path.GetExtension(file.FileName);
                    randomFile = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid().ToString("N") + extension;

                    var filePath = Path.Combine(Server.MapPath(uploadDir), randomFile);
                    file.SaveAs(filePath);

                    teamMembers.Image     = randomFile;
                    teamMembers.CreatedBy = User.Identity.GetUserId();
                    teamMembers.CreatedOn = DateTime.UtcNow.AddHours(5);

                    db.TeamMembers.Add(teamMembers);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(teamMembers));
        }
Beispiel #16
0
 public void UpdateTeamMembers(IReadOnlyCollection <ScoringApplicationTeamMember> teamMembers)
 {
     TeamMembers.Clear();
     foreach (var teamMember in teamMembers)
     {
         TeamMembers.Add(teamMember);
     }
 }
Beispiel #17
0
 /// <summary>
 /// Adds a team member to the team.
 /// </summary>
 /// <param name="teamMember">The team member to add.</param>
 /// <param name="role">The role that the team member had on this team.</param>
 public void AddTeamMember(TeamMember teamMember, Role role)
 {
     TeamMembers.Add(new TeamTeamMember()
     {
         TeamMember = teamMember,
         Role       = role
     });
 }
Beispiel #18
0
 /// <summary>
 /// Adds a team member to the team.
 /// </summary>
 /// <param name="teamMemberId">The team member ID to add.</param>
 /// <param name="roleId">The role ID that the team member had on this team.</param>
 public void AddTeamMember(int teamMemberId, int roleId)
 {
     TeamMembers.Add(new TeamTeamMember()
     {
         TeamMemberId = teamMemberId,
         RoleId       = roleId
     });
 }
Beispiel #19
0
        public ActionResult DeleteConfirmed(long id)
        {
            TeamMembers teamMembers = db.TeamMembers.Find(id);

            db.TeamMembers.Remove(teamMembers);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #20
0
        public void UpdateTeamMemberPhotoLink(long memberId, string link)
        {
            var member = TeamMembers.FirstOrDefault(i => i.Id == memberId);

            if (member != null)
            {
                member.PhotoUrl = link;
            }
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            TeamMembers teamMembers = await db.TeamMembers.FindAsync(id);

            db.TeamMembers.Remove(teamMembers);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        private void UpdateLeaders(OmadaTeam team)
        {
            List <OmadaUser> updatedLeaders = TeamMembers.Where(m => m.IsLeader == true).Select(m => m.User).ToList();

            teamData.SetNoLeaders(team);
            foreach (var member in updatedLeaders)
            {
                teamData.UpdateLeaderStatus(member.Id, team);
            }
        }
Beispiel #23
0
        public TestData WithDummyUser(bool registerDummy)
        {
            if (!registerDummy)
            {
                return(this);
            }

            TeamMembers = TeamMembers.Union(new[] { DummyMember }).ToList();
            return(this);
        }
Beispiel #24
0
        public void RemoveSelectedMember()
        {
            if (SelectedMember != null)
            {
                AvailablePlayers.Add(SelectedMember);
                TeamMembers.Remove(SelectedMember);
            }

            ValidateAllData();
        }
Beispiel #25
0
        public async Task <IActionResult> OnGet(int teamID)
        {
            if (LoggedInUser == null)
            {
                return(Challenge());
            }

            if (EventRole != EventRole.play)
            {
                return(Forbid());
            }

            if (!Event.IsTeamMembershipChangeActive)
            {
                return(NotFound("Team membership change is not currently allowed."));
            }

            TeamMembers playerTeam = await(from member in _context.TeamMembers
                                           where member.Member == LoggedInUser &&
                                           member.Team.Event == Event
                                           select member).FirstOrDefaultAsync();

            if (playerTeam != null)
            {
                return(RedirectToPage("./Details", new { eventId = Event.ID, eventRole = EventRole, teamId = playerTeam.Team.ID }));
            }

            Team = await(from Team t in _context.Teams
                         where t.ID == teamID && t.Event == Event
                         select t).FirstOrDefaultAsync();

            if (Team == null)
            {
                return(NotFound());
            }

            // Only handle one application at a time for a player to avoid spamming all teams
            IEnumerable <TeamApplication> oldApplications = from TeamApplication oldApplication in _context.TeamApplications
                                                            where oldApplication.Player == LoggedInUser && oldApplication.Team.Event == Event
                                                            select oldApplication;

            _context.TeamApplications.RemoveRange(oldApplications);

            TeamApplication application = new TeamApplication()
            {
                Team   = Team,
                Player = LoggedInUser
            };

            _context.TeamApplications.Add(application);

            await _context.SaveChangesAsync();

            return(Page());
        }
Beispiel #26
0
        public ActionResult AboutUs()
        {
            List <CustomerMessage> customer = new List <CustomerMessage>();
            PDBC db = new PDBC("DBConnectionString", true);

            db.Connect();
            DataTable dt = db.Select(
                "SELECT [name],[Job],[message],[star],[ImagePath],[ImageValue]FROM [TSHP_PortalCMS].[dbo].[CustomersMessge_tbl]");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var cust = new CustomerMessage()
                {
                    Name    = dt.Rows[i]["name"].ToString(),
                    Job     = dt.Rows[i]["Job"].ToString(),
                    Message = dt.Rows[i]["message"].ToString(),
                    Stars   = (int)dt.Rows[i]["star"]
                };

                customer.Add(cust);
            }


            List <TeamMembers> members = new List <TeamMembers>();

            DataTable dt2 =
                db.Select(
                    "SELECT[Name],[Job],[Tozihat],[github],[Linkedin],[Instagram],[ImagePath],[ImageValue]FROM [TSHP_PortalCMS].[dbo].[TeamMembers_tbl]");

            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                var member = new TeamMembers()
                {
                    name      = dt2.Rows[i]["Name"].ToString(),
                    Job       = dt2.Rows[i]["Job"].ToString(),
                    Tozihat   = dt2.Rows[i]["Tozihat"].ToString(),
                    Github    = dt2.Rows[i]["github"].ToString(),
                    linkedin  = dt2.Rows[i]["Linkedin"].ToString(),
                    Instagram = dt2.Rows[i]["Instagram"].ToString(),
                    ImagePath = dt2.Rows[i]["ImagePath"].ToString(),
                    //  ImageValue = dt2.Rows[i]["ImageValue"].ToString()
                };

                members.Add(member);
            }


            var About__Us = new AboutUsModelView()
            {
                customerMessages = customer,
                teamMemberses    = members
            };

            return(View(About__Us));
        }
        /// <summary>
        /// Adds a user to a team after performing a number of checks to make sure that the change is valid
        /// </summary>
        /// <param name="context">The context to update</param>
        /// <param name="Event">The event that the team is for</param>
        /// <param name="EventRole">The event role of the user that is making this change</param>
        /// <param name="teamId">The id of the team the player should be added to</param>
        /// <param name="userId">The user that should be added to the team</param>
        /// <returns>
        /// A tuple where the first element is a boolean that indicates whether the player was successfully
        /// added to the team and the second element is a message to display that explains the error in the
        /// case where the user was not successfully added to the team
        /// </returns>
        public static async Task <Tuple <bool, string> > AddMemberAsync(PuzzleServerContext context, Event Event, EventRole EventRole, int teamId, int userId)
        {
            Team team = await context.Teams.FirstOrDefaultAsync(m => m.ID == teamId);

            if (team == null)
            {
                return(new Tuple <bool, string>(false, $"Could not find team with ID '{teamId}'. Check to make sure the team hasn't been removed."));
            }

            var currentTeamMembers = await context.TeamMembers.Where(members => members.Team.ID == team.ID).ToListAsync();

            if (currentTeamMembers.Count >= Event.MaxTeamSize && EventRole != EventRole.admin)
            {
                return(new Tuple <bool, string>(false, $"The team '{team.Name}' is full."));
            }

            PuzzleUser user = await context.PuzzleUsers.FirstOrDefaultAsync(m => m.ID == userId);

            if (user == null)
            {
                return(new Tuple <bool, string>(false, $"Could not find user with ID '{userId}'. Check to make sure the user hasn't been removed."));
            }

            if (user.EmployeeAlias == null && currentTeamMembers.Where((m) => m.Member.EmployeeAlias == null).Count() >= Event.MaxExternalsPerTeam)
            {
                return(new Tuple <bool, string>(false, $"The team '{team.Name}' is already at its maximum count of non-employee players, and '{user.Email}' has no registered alias."));
            }

            if (await(from teamMember in context.TeamMembers
                      where teamMember.Member == user &&
                      teamMember.Team.Event == Event
                      select teamMember).AnyAsync())
            {
                return(new Tuple <bool, string>(false, $"'{user.Email}' is already on a team in this event."));
            }

            TeamMembers Member = new TeamMembers();

            Member.Team   = team;
            Member.Member = user;

            // Remove any applications the user might have started for this event
            var allApplications = from app in context.TeamApplications
                                  where app.Player == user &&
                                  app.Team.Event == Event
                                  select app;

            context.TeamApplications.RemoveRange(allApplications);

            context.TeamMembers.Add(Member);
            await context.SaveChangesAsync();

            return(new Tuple <bool, string>(true, ""));
        }
Beispiel #28
0
        public int add(TeamMembers teamMembers)
        {
            int datarows = 0;

            if (teamMembers.MemberName != null)
            {
                datarows = this._db.Execute(@"INSERT TeamMembers([MemberName],[AdminRights],[Availability]) values (@MemberName,@AdminRights,@Availability)",
                                            new { MemberName = teamMembers.MemberName, AdminRights = teamMembers.AdminRights, Availability = teamMembers.Availability });
            }
            return(datarows);
        }
Beispiel #29
0
        public void CreatePlayer()
        {
            PlayerModel player = new PlayerModel(FirstName, LastName);

            SqlDataHandler.CreatePlayer(player);
            TeamMembers.Add(player);
            ValidateAllData();

            FirstName = null;
            LastName  = null;
        }
Beispiel #30
0
 private void UpdateSearchUI()
 {
     if (TeamMembers.Any(user => user.Id == SearchResultUser.Id))
     {
         switchButtonState(AddToTeamButton, false);
     }
     else
     {
         switchButtonState(AddToTeamButton, true);
     }
 }
Beispiel #31
0
        public object Get(TeamMembers request)
        {
            if (request.TeamId == -1) return UnauthorizedResponse();

            try {
                using (var conn = DbHelper.OpenConnection()) {
                    var cmd = new MySqlCommand {
                        Connection = conn,
                        CommandText = "GetTeamMembers",
                        CommandType = CommandType.StoredProcedure,
                    };
                    cmd.Parameters.AddWithValue("TeamId", request.TeamId);

                    var response = new Dictionary<string, dynamic> { { "success", 0 }, { "error", 0 } };
                    var reader = cmd.ExecuteReader();

                    if (reader.HasRows) {
                        response["success"] = 1;
                        var i = 0;
                        while (reader.Read()) {
                            if (i == 0) response["tname"] = reader.GetString("t_name");

                            response.AddToDynamicList("teammembers", new {
                                id = reader.GetInt64("u_id"),
                                nickname = reader.GetString("u_nickname"),
                                time_spent = reader.IsDBNull("time_spent") ? 0 : reader.GetInt64("time_spent"),
                            });
                            i++;
                        }
                    } else {
                        response["error"] = 1;
                        response["error_msg"] = "No teams or teammates found.";
                    }

                    return response;
                }
            } catch (Exception e) {
                Log.Error(e.Message, e);
                throw;
            }
        }