Esempio n. 1
0
        public TeamDetail getTeamMember(SqlConnection con, int memberID)
        {
            DataTable  dt            = new DataTable();
            TeamDetail objTeamMember = null;

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from T_Team_Detail WHERE memberID=" + memberID.ToString(), con);

                da.Fill(dt);
                da.Dispose();

                if (dt.Rows.Count == 0)
                {
                    return(null);
                }
                objTeamMember                  = new TeamDetail();
                objTeamMember.intMemberID      = dt.Rows[0].Field <int>("MemberID");
                objTeamMember.intTeamID        = dt.Rows[0].Field <int>("TeamID");
                objTeamMember.strMemberName    = dt.Rows[0].Field <string>("MemberName");
                objTeamMember.strRemarks       = dt.Rows[0].Field <string>("Remarks");
                objTeamMember.strContactNo     = dt.Rows[0].Field <string>("ContactNo");
                objTeamMember.intDesignationID = dt.Rows[0].Field <int>("DesignationID");
                objTeamMember.intDeptID        = dt.Rows[0].Field <int>("DeptID");
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(objTeamMember);
        }
Esempio n. 2
0
        public int SaveOrUpdateDetail(TeamDetail objTeamDetail, SqlConnection con)
        {
            SqlCommand     com   = null;
            SqlTransaction trans = null;

            try
            {
                com             = new SqlCommand();
                trans           = con.BeginTransaction();
                com.Transaction = trans;
                com.Connection  = con;

                com.CommandText = "spInsertUpdateTeamDetail";
                com.Parameters.Add("@memberID", SqlDbType.Int).Value = objTeamDetail.intMemberID;
                com.Parameters.Add("@TeamID", SqlDbType.Int).Value   = objTeamDetail.intTeamID;

                com.Parameters.Add("@MemberName", SqlDbType.VarChar, 100).Value = objTeamDetail.strMemberName;
                com.Parameters.Add("@DesignationID", SqlDbType.Int).Value       = objTeamDetail.intDesignationID;
                com.Parameters.Add("@DeptID", SqlDbType.Int).Value             = objTeamDetail.intDeptID;
                com.Parameters.Add("@ContactNo", SqlDbType.VarChar, 100).Value = objTeamDetail.strContactNo;
                com.Parameters.Add("@Remarks", SqlDbType.VarChar, 500).Value   = objTeamDetail.strRemarks;

                com.CommandType = CommandType.StoredProcedure;
                com.ExecuteNonQuery();
                trans.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to Save or Update " + ex.Message);
            }
            return(0);
        }
Esempio n. 3
0
        public IActionResult Patch(string id, [FromBody] JsonPatchDocument <TeamDet> teamDetPatch)
        {
            try
            {
                if (Guid.TryParse(id, out Guid parsedId))
                {
                    //var userId = User.FindFirstValue("sub");

                    TeamDetail teamDetail = _unitOfWork.TeamDetails.Get(parsedId);

                    TeamDet teamDet = _mapper.Map <TeamDet>(teamDetail);

                    teamDetPatch.ApplyTo(teamDet);

                    _mapper.Map(teamDet, teamDetail);

                    _unitOfWork.Complete();

                    return(CreatedAtRoute("Get", new { id = _mapper.Map <TeamDet>(teamDetail).Id }, _mapper.Map <TeamDet>(teamDetail)));
                }
            }
            catch (Exception e)
            {
                string message = e.Message;
            }

            return(BadRequest());
        }
        public IHttpActionResult PutTeamDetail(int id, TeamDetail teamDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != teamDetail.Id)
            {
                return(BadRequest());
            }

            db.Entry(teamDetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeamDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 5
0
        public TeamDetail GetTeamDetailByTeamResponse(IStat stat, TeamResponse team, IList <StatResponse> matchStats)
        {
            var teamDetail = new TeamDetail {
                TeamInfo = team
            };
            var teamTotalAge = 0;
            var teamStats    = new StatResponse();

            var players = matchStats.Where(p => p.TeamId == team.Id).Select(p => p.Player).ToList();

            foreach (var player in players)
            {
                var playerStat = stat.GetPlayerStatByMatchIdAndTeamId(player.Id, team.Id, matchStats);
                if (playerStat == null)
                {
                    continue;
                }

                teamStats = stat.AddPlayerStatToTeamStats(teamStats, playerStat);

                teamDetail.PlayerStats.Add(new PlayerMatchStat {
                    Player = player, Stat = playerStat
                });
                teamTotalAge = teamTotalAge + player.BirthDate.GetAge();
            }

            teamDetail.AgeRatio = ConvertFunctions.GetTeamAgeRatio(players.Count, teamTotalAge);

            teamDetail.TeamStats = teamStats;
            return(teamDetail);
        }
Esempio n. 6
0
        public static string NextGameSummary(GameScheduleData nextGame, TeamDetail teamData)
        {
            var game          = nextGame.Dates[0].Games[0];
            var gamelocaltime = game.GameDate.AddHours(teamData.Venue.TimeZone.Offset);
            var gameTime      = gamelocaltime.ToLongDateString() + " at " + gamelocaltime.ToShortTimeString() + " " + teamData.Venue.TimeZone.TZ;

            return(string.Format("The next {0} game is {1}, {2} @ {3} at {4}", teamData.Name, gameTime, game.Teams.Away.Team.Name, game.Teams.Home.Team.Name, game.Venue.Name));
        }
Esempio n. 7
0
        public async Task <bool> UpdateTeamDetail(PlayerCardDto teamDetail)
        {
            TeamDetail td = _content.TeamDetails.FirstOrDefault(x => x.UserId == teamDetail.userId && x.Position == teamDetail.CardPosition);

            td.PlayerId = teamDetail.PlayerId;
            _content.TeamDetails.Update(td);
            return(await _content.SaveChangesAsync() > 0);
        }
Esempio n. 8
0
        ///<inheritdoc/>
        public Uri SaveTeam(TeamDetail team)
        {
            if (team == null)
            {
                throw new ArgumentNullException(nameof(team));
            }

            return(SaveResource(team, "team"));
        }
Esempio n. 9
0
        ///*[ProjectManagerRequired]*/
        public ActionResult ConfirmAssignTeam(int taskId, int teamId)
        {
            TeamService     repoTeam     = new TeamService();
            EmployeeService repoEmployee = new EmployeeService();
            Team            team         = repoTeam.Get(teamId);
            TeamDetail      teamDetail   = new TeamDetail(team, repoEmployee.Get(team.TeamManagerId), repoEmployee.GetByTeamId(teamId).Select(e => new EmployeeListItem(e)));

            return(View(teamDetail));
        }
        /// <summary>
        /// This method delete the team detail record from table.
        /// </summary>
        /// <param name="teamEntity">Team configuration table entity.</param>
        /// <returns>A <see cref="Task"/> of type bool where true represents entity record is successfully deleted from table while false indicates failure in deleting data.</returns>
        public async Task <bool> DeleteTeamDetailAsync(TeamDetail teamEntity)
        {
            await this.EnsureInitializedAsync();

            TableOperation insertOrMergeOperation = TableOperation.Delete(teamEntity);
            TableResult    result = await this.CloudTable.ExecuteAsync(insertOrMergeOperation);

            return(result.HttpStatusCode == (int)HttpStatusCode.NoContent);
        }
Esempio n. 11
0
        ///<inheritdoc/>
        public bool UpdateTeam(TeamDetail team)
        {
            if (team == null)
            {
                throw new ArgumentNullException(nameof(team));
            }

            return(UpdateResource(team, "team/" + team.Id));
        }
        /// <summary>
        /// Store or update team detail in Azure table storage.
        /// </summary>
        /// <param name="teamEntity">Represents team entity used for storage and retrieval.</param>
        /// <returns><see cref="Task"/> that represents team entity is saved or updated.</returns>
        public async Task <bool> StoreOrUpdateTeamDetailAsync(TeamDetail teamEntity)
        {
            await this.EnsureInitializedAsync();

            teamEntity = teamEntity ?? throw new ArgumentNullException(nameof(teamEntity));
            TableOperation addOrUpdateOperation = TableOperation.InsertOrReplace(teamEntity);
            var            result = await this.CloudTable.ExecuteAsync(addOrUpdateOperation);

            return(result.HttpStatusCode == (int)HttpStatusCode.NoContent);
        }
        public IHttpActionResult GetTeamDetail(int id)
        {
            TeamDetail teamDetail = db.TeamDetails.Find(id);

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

            return(Ok(teamDetail));
        }
        public IHttpActionResult PostTeamDetail(TeamDetail teamDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TeamDetails.Add(teamDetail);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = teamDetail.Id }, teamDetail));
        }
Esempio n. 15
0
        public async Task AddMemberAsync(TeamMemberBindingModel model, int teamId)
        {
            var mem = new TeamDetail
            {
                TeamId     = teamId,
                UserId     = model.UserId,
                RoleInTeam = "Member"
            };
            await _db.TeamDetails.AddAsync(mem);

            await _db.SaveChangesAsync();
        }
        public IHttpActionResult DeleteTeamDetail(int id)
        {
            TeamDetail teamDetail = db.TeamDetails.Find(id);

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

            db.TeamDetails.Remove(teamDetail);
            db.SaveChanges();

            return(Ok(teamDetail));
        }
        public async Task <IActionResult> UpdateTeamDetailRecord(PlayerCardDto playerDto)
        {
            // _logger.LogInformation("Demo Logging Information in Index Method");

            // Need to get the correct Id for the current cardPosition for the User
            var existingTeamDetailForPosition = _repo.GetTeamDetailForPosition(playerDto.userId, playerDto.CardPosition);

            // _logger.LogInformation("existing teamDetail for position is now being set");

            if (existingTeamDetailForPosition != null)
            {
                // This needs to be updated
                var teamDetailToUpdate = new TeamDetail
                {
                    Active    = 1,
                    Captain   = playerDto.isCaptain,
                    Emergency = playerDto.isEmergency,
                    Id        = existingTeamDetailForPosition.Id,
                    PlayerId  = playerDto.PlayerId,
                    Position  = playerDto.CardPosition,
                    SixthMan  = playerDto.isSixthMan,
                    UserId    = playerDto.userId
                };

                // Now need to call the update method of the TeamDetail
                // _logger.LogInformation("About to call to the Update Team Detail Repo");

                var updateSalary = await _repo.UpdateTeamDetail(teamDetailToUpdate);

                // _logger.LogInformation("Returned from the Update Team Detail repo - with status of: " + updateSalary);
                return(StatusCode(201));
            }
            else
            {
                // This is a new Team Detail record - realistically it should never get here
                var teamDetailToCreate = new TeamDetail
                {
                    Captain   = playerDto.isCaptain,
                    Emergency = playerDto.isEmergency,
                    SixthMan  = playerDto.isSixthMan,
                    Active    = 1,
                    PlayerId  = playerDto.PlayerId,
                    Position  = playerDto.CardPosition,
                    UserId    = playerDto.userId
                };
                var createdTeamDetail = await _repo.CreateTeamDetailRecord(teamDetailToCreate);

                return(StatusCode(201));
            }
        }
Esempio n. 18
0
        public string AddTeam(Team newTeam)
        {
            if (newTeam == null)
            {
                throw new ArgumentNullException($"Team is null");
            }
            var teamAddKey  = _teamRepository.Create(newTeam);
            var newuserteam = new TeamDetail
            {
                Name = newTeam.Name
            };

            _teamdetailRepository.CreateWithId(teamAddKey, newuserteam);
            return(teamAddKey);
        }
        public async Task <IActionResult> CreateTeamDetail(TeamDetailForPlayerDto teamDetailDto)
        {
            var teamDetailToCreate = new TeamDetail
            {
                Captain   = teamDetailDto.Captain,
                Emergency = teamDetailDto.Emergency,
                SixthMan  = teamDetailDto.SixthMan,
                Active    = 1,
                PlayerId  = teamDetailDto.PlayerId,
                Position  = teamDetailDto.Position,
                UserId    = teamDetailDto.UserId
            };
            var createdTeamDetail = await _repo.CreateTeamDetailRecord(teamDetailToCreate);

            return(StatusCode(201));
        }
Esempio n. 20
0
        public IHttpActionResult Put(TeamDetail team)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = new TeamService(Guid.Parse(User.Identity.GetUserId()));

            if (!service.EditTeam(team))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Esempio n. 21
0
        public IActionResult Get(string id)
        {
            try
            {
                if (Guid.TryParse(id, out Guid parsedId))
                {
                    TeamDetail teamDetail = _unitOfWork.TeamDetails.GetDetail(parsedId, true);

                    return(Ok(_mapper.Map <TeamDet>(teamDetail)));
                }
            }
            catch (Exception e)
            {
                string message = e.Message;
            }

            return(NotFound());
        }
Esempio n. 22
0
        public void UpdateTeam(string teamId, TeamDetail updateTeamDetail)
        {
            if (updateTeamDetail == null)
            {
                throw new ArgumentNullException($"Team is null");
            }
            if (string.IsNullOrEmpty(teamId))
            {
                throw new ArgumentException($"Team ID is null");
            }
            var updateteam = new Team
            {
                Name = updateTeamDetail.Name
            };

            _teamRepository.CreateWithId(teamId, updateteam);
            _teamdetailRepository.CreateWithId(teamId, updateTeamDetail);
        }
Esempio n. 23
0
 public ActionResult ConfirmAssignTeam(int taskId, TeamDetail collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             TaskService repoTask = new TaskService();
             if (repoTask.AssignTeam(taskId, collection.Id))
             {
                 return(RedirectToAction("Details", new { id = taskId }));
             }
             return(RedirectToAction("AssignTeam", new { id = taskId }));
         }
         return(RedirectToAction("AssignTeam", new { id = taskId }));
     }
     catch (Exception)
     {
         return(RedirectToAction("AssignTeam", new { id = taskId }));
     }
 }
Esempio n. 24
0
        // GET: Team/Details/5
        public ActionResult Details(int id)
        {
            TeamService teamRepo = new TeamService();

            CD.Team                   team         = teamRepo.Get(id);
            EmployeeService           employeeRepo = new EmployeeService();
            DocumentService           repoDoc      = new DocumentService();
            IEnumerable <CD.Employee> employees    = employeeRepo.GetByTeamId(id);
            List <EmployeeListItem>   finalList    = new List <EmployeeListItem>();

            foreach (CD.Employee employee in employees)
            {
                finalList.Add(new EmployeeListItem(employee));
            }
            MessageService repoMessage = new MessageService();
            IEnumerable <ConversationListItem> conversations = repoMessage.GetTeamMessages(id).Select(m => new ConversationListItem(new M.Message(m), new M.Message(repoMessage.GetLastMessage(m.Id)), team));
            IEnumerable <DocumentList>         docs          = repoDoc.GetByTeam(id).Select(d => new DocumentList(d));
            TeamDetail teamDetail = new TeamDetail(team, employeeRepo.Get(team.TeamManagerId), finalList, conversations, docs);

            return(View(teamDetail));
        }
Esempio n. 25
0
        public static void ClassInit(TestContext context)
        {
            //Arrange
            Team = new Team {
                Name = "TeamName"
            };
            TeamDetail = new TeamDetail {
                Name = Team.Name
            };
            var teams = new List <Team> {
                Team
            };
            var mockTeamRepo = new Mock <IRepository <Team> >();

            mockTeamRepo.Setup(x => x.Create(It.IsAny <Team>())).Returns("TeamId");
            mockTeamRepo.Setup(x => x.GetList()).Returns(teams);
            var mockTeamDetailRepo = new Mock <IRepository <TeamDetail> >();

            mockTeamDetailRepo.Setup(x => x.GetItem(It.IsAny <string>())).Returns(TeamDetail);
            TeamService = new TeamService(mockTeamRepo.Object, mockTeamDetailRepo.Object);
        }
Esempio n. 26
0
        public static string PeriodSummary(LineScorePeriod lineScorePeriod, TeamDetail home, TeamDetail away, NHLApi.GameDetail gameDetail)
        {
            /*
             *  Period X:
             *  Shots: <HomeTeam> X, <AwayTeam> Y
             *  Goals: <HomeTeam> X, <AwayTeam> Y
             *  Scoring Plays:
             *  .
             *  .
             *  .
             */
            var playIndexStart = gameDetail.LiveData.Plays.PlaysByPeriod[lineScorePeriod.Num - 1].StartIndex;
            var playIndexEnd   = gameDetail.LiveData.Plays.PlaysByPeriod[lineScorePeriod.Num - 1].EndIndex;

            var builder = new StringBuilder();

            builder.AppendLine(String.Format("**Period {0}:**", lineScorePeriod.Num));
            builder.AppendLine(String.Format("__Shots:__ {0} {1}, {2} {3}", home.Abbreviation, lineScorePeriod.Home.ShotsOnGoal, away.Abbreviation, lineScorePeriod.Away.ShotsOnGoal));
            builder.AppendLine(String.Format("__Goals:__ {0} {1}, {2} {3}", home.Abbreviation, lineScorePeriod.Home.Goals, away.Abbreviation, lineScorePeriod.Away.Goals));



            var scoringPlays = GetScoringPlaysForPeriod(gameDetail, playIndexStart, playIndexEnd);

            if (scoringPlays.Count() > 0)
            {
                builder.AppendLine("__Scoring Plays:__");

                foreach (var play in scoringPlays)
                {
                    builder.AppendLine(" - " + play);
                }
            }
            else
            {
                builder.AppendLine(" - No Goals were scored this period.");
            }

            return(builder.ToString());
        }
Esempio n. 27
0
        public async Task AddTeamAsync(TeamViewModel model)
        {
            var team = new UserTeam
            {
                TeamName   = model.TeamName,
                TeamLeadId = model.UserId
            };

            var addteam = await _db.UserTeams.AddAsync(team);

            if (addteam != null && team.TeamLeadId != null)
            {
                var teamlead = new TeamDetail
                {
                    TeamId     = team.Id,
                    RoleInTeam = "Team Lead",
                    UserId     = model.UserId,
                };
                await _db.TeamDetails.AddAsync(teamlead);
            }

            await _db.SaveChangesAsync();
        }
Esempio n. 28
0
        public bool EditTeam(TeamDetail model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Teams
                    .Single(e => e.TeamId == model.TeamId);

                if (entity.UserId == _userId)
                {
                    entity.TeamId      = model.TeamId;
                    entity.TeamName    = model.TeamName;
                    entity.TotalPoints = model.TotalPoints;

                    return(ctx.SaveChanges() == 1);
                }
                else
                {
                    return(false);
                }
            }
        }
Esempio n. 29
0
        public async Task <IActionResult> GetTeamDetailsAsync(string teamId)
        {
            try
            {
                var userClaims = this.GetUserClaims();

                var teamsChannelAccounts = new List <TeamsChannelAccount>();
                IEnumerable <ChannelInfo> teamsChannelInfo = new List <ChannelInfo>();
                var conversationReference = new ConversationReference
                {
                    ChannelId  = teamId,
                    ServiceUrl = userClaims.ServiceUrl,
                    Bot        = new ChannelAccount()
                    {
                        Id = $"28:{this.appId}"
                    },
                    Conversation = new ConversationAccount()
                    {
                        ConversationType = Constants.ChannelConversationType, IsGroup = true, Id = teamId, TenantId = this.options.Value.TenantId
                    },
                };

                await this.botAdapter.ContinueConversationAsync(
                    this.appId,
                    conversationReference,
                    async (context, token) =>
                {
                    string continuationToken = null;
                    do
                    {
                        var currentPage   = await TeamsInfo.GetPagedMembersAsync(context, 100, continuationToken, CancellationToken.None);
                        continuationToken = currentPage.ContinuationToken;
                        teamsChannelAccounts.AddRange(currentPage.Members);
                    }while (continuationToken != null);

                    teamsChannelInfo = await TeamsInfo.GetTeamChannelsAsync(context, teamId, CancellationToken.None);
                },
                    default);

                this.logger.LogInformation("GET call for fetching team members and channels from team roster is successful");
                teamsChannelInfo.First(channel => channel.Name == null).Name = Strings.GeneralChannel;

                var teamDetails = new TeamDetail
                {
                    TeamMembers = teamsChannelAccounts
                                  .Select(
                        member => new TeamMember
                    {
                        Content         = member.Email,
                        Header          = member.Name,
                        AzureAdObjectId = member.AadObjectId,
                    }),
                    Channels = teamsChannelInfo
                               .Select(
                        member => new TeamAccount
                    {
                        ChannelId = member.Id,
                        Header    = member.Name,
                    }),
                };

                return(this.Ok(teamDetails));
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex, "Error occurred while getting team member list.");
                throw;
            }
        }
Esempio n. 30
0
        public static string GameSummary(ScheduleData scheduleData, GameScheduleData nextGame, TeamDetail teamData)
        {
            // Final Score: <Home Team> X, <Away Team> Y
            // Next Game: <Next Game for Config'd Team>
            var builder = new StringBuilder();

            builder.AppendLine(String.Format("Final Score: {0} {1}, {2} {3}", scheduleData.Dates[0].Games[0].Teams.Home.Team.Name, scheduleData.Dates[0].Games[0].Teams.Home.Score, scheduleData.Dates[0].Games[0].Teams.Away.Team.Name, scheduleData.Dates[0].Games[0].Teams.Away.Score));
            builder.AppendLine(NextGameSummary(nextGame, teamData));

            return(builder.ToString());
        }