示例#1
0
        public async Task <IActionResult> Index()
        {
            var team = await _context.Teams.SingleOrDefaultAsync(m => m.Slug == TeamSlug);

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

            var user = await _userManager.GetUserAsync(User);

            var userCanEdit = User.IsInRole(ApplicationRoleCodes.Admin) ||
                              user.TeamPermissions.Any(a => a.TeamId == team.Id && a.Role.Name == TeamRole.Codes.Admin);

            var model = new TeamDetailsModel
            {
                Name               = team.Name,
                Slug               = team.Slug,
                ContactName        = team.ContactName,
                ContactEmail       = team.ContactEmail,
                ContactPhoneNumber = team.ContactPhoneNumber,
                ApiKey             = userCanEdit ? team.ApiKey : "",
                IsActive           = team.IsActive,
                UserCanEdit        = userCanEdit
            };

            return(View(model));
        }
示例#2
0
        public async Task <IActionResult> Roles()
        {
            var team = await _context.Teams.SingleOrDefaultAsync(m => m.Slug == TeamSlug && m.IsActive);

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

            var permissions = await _context.TeamPermissions
                              .Include(a => a.Role)
                              .Include(a => a.User)
                              .Where(a => a.TeamId == team.Id)
                              .ToListAsync();

            var user = await _userManager.GetUserAsync(User);

            var userCanEdit = User.IsInRole(ApplicationRoleCodes.Admin) ||
                              user.TeamPermissions.Any(a => a.TeamId == team.Id && a.Role.Name == TeamRole.Codes.Admin);

            var model = new TeamDetailsModel
            {
                Name               = team.Name,
                Slug               = team.Slug,
                ContactName        = team.ContactName,
                ContactEmail       = team.ContactEmail,
                ContactPhoneNumber = team.ContactPhoneNumber,
                IsActive           = team.IsActive,
                Permissions        = permissions,
                UserCanEdit        = userCanEdit
            };

            return(View(model));
        }
示例#3
0
        public async Task <IActionResult> Index()
        {
            // admins can look at inactive teams
            Team team;

            if (User.IsInRole(ApplicationRoleCodes.Admin))
            {
                team = await _context.Teams
                       .Include(a => a.Accounts)
                       .SingleOrDefaultAsync(m => m.Slug == TeamSlug);
            }
            else
            {
                team = await _context.Teams
                       .Include(a => a.Accounts)
                       .SingleOrDefaultAsync(m => m.Slug == TeamSlug && m.IsActive);
            }

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

            var defaultCount = team.Accounts.Count(a => a.IsActive && a.IsDefault);

            if (defaultCount == 0)
            {
                Message = "Warning! There is no active default account. Please set one account as your default";
            }
            else if (defaultCount > 1)
            {
                Message = "Warning! There are multiple active default accounts. Please set only one as your default.";
            }

            var user = await _userManager.GetUserAsync(User);

            var userCanEdit = User.IsInRole(ApplicationRoleCodes.Admin) ||
                              user.TeamPermissions.Any(a => a.TeamId == team.Id && a.Role.Name == TeamRole.Codes.Admin);

            var model = new TeamDetailsModel
            {
                Name               = team.Name,
                Slug               = team.Slug,
                ContactName        = team.ContactName,
                ContactEmail       = team.ContactEmail,
                ContactPhoneNumber = team.ContactPhoneNumber,
                IsActive           = team.IsActive,
                Accounts           = team.Accounts,
                UserCanEdit        = userCanEdit
            };

            return(View(model));
        }
示例#4
0
        public ActionResult Index(int id)
        {
            var dataservice = DataService.GetInstance();
            var team        = dataservice.Teams.FirstOrDefault(t => t.Id == id);

            var model = new TeamDetailsModel
            {
                Id      = team.Id,
                Name    = team.Name,
                Persons = dataservice.People.Where(p => p.Team?.Id == id).ToList()
            };

            return(View(model));
        }
示例#5
0
        // GET: Entry/Details/5
        public ActionResult Details(int id)
        {
            if (id == 0)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            var TeamData         = (from a in db.StudentTeams where a.TeamID == id select a).FirstOrDefault();
            var Round1           = (from a in db.RoundEntries where a.TeamID == id && a.Round == 1 select a).FirstOrDefault();
            var Round2           = (from a in db.RoundEntries where a.TeamID == id && a.Round == 2 select a).FirstOrDefault();
            var TeamDetailsModel = new TeamDetailsModel();

            TeamDetailsModel.TeamName           = TeamData.TeamName;
            TeamDetailsModel.TeamID             = TeamData.TeamID;
            TeamDetailsModel.TeamNumberBranch   = TeamData.TeamNumberBranch;
            TeamDetailsModel.TeamNumberSpecific = TeamData.TeamNumberSpecific;
            TeamDetailsModel.Location           = TeamData.Location;
            TeamDetailsModel.Coach  = TeamData.Coach;
            TeamDetailsModel.CompID = TeamData.CompID;
            int i       = 0;
            int average = 0;

            //bool R1Rerun = false;
            //bool R2Rerun = false;
            foreach (var round in db.RoundEntries.Where(a => a.TeamID == id && a.Rerun == true).OrderBy(a => a.Round).ToList())
            {
                i++;
                var Round = (from a in db.RoundEntries where a.TeamID == id && a.Round == round.Round && a.Rerun == round.Rerun select a).FirstOrDefault();
                if (Round.Usable == true)
                {
                    average = average + Round.Score;
                }
                TeamDetailsModel.Round.Add(Round);
            }
            foreach (var round in db.RoundEntries.Where(a => a.TeamID == id && a.Rerun == false).OrderBy(a => a.Round).ToList())
            {
                i++;
                var Round = (from a in db.RoundEntries where a.TeamID == id && a.Round == round.Round && a.Rerun == round.Rerun select a).FirstOrDefault();
                if (Round.Usable == true)
                {
                    average = average + Round.Score;
                }
                TeamDetailsModel.Round.Add(Round);
            }
            TeamDetailsModel.RoundAverage = average / 2;
            return(View(TeamDetailsModel));
        }
        public void GetTeam()
        {
            TestWrapper(async(TwitchConnection connection) =>
            {
                UserModel user = await UsersServiceUnitTests.GetCurrentUser(connection);

                IEnumerable <TeamModel> results = await connection.NewAPI.Teams.GetChannelTeams(user);

                Assert.IsNotNull(results);
                Assert.IsTrue(results.Count() > 0);

                TeamDetailsModel team = await connection.NewAPI.Teams.GetTeam(results.First().id);

                Assert.IsNotNull(team);
                Assert.AreEqual(results.First().id, team.id);
            });
        }
示例#7
0
        private void processSofifaHTML(string teamSofifaHTML, ref TeamDetailsModel teamModel)
        {
            ScorerDetails        scorerDetails = new ScorerDetails();
            List <ScorerDetails> listOfScorer  = new List <ScorerDetails>();
            DataTable            dt            = null;

            int     position                 = 0;
            int     htmlFinish               = 0;
            Boolean playerFound              = true;
            string  playerDetailsHtml        = String.Empty;
            int     positonStartPlayerDetals = 0;
            int     positonEndPlayerDetals   = 0;

            string id       = String.Empty;
            string nickname = String.Empty;
            string name     = String.Empty;
            string link     = String.Empty;
            string country  = String.Empty;
            string rating   = String.Empty;

            try
            {
                position       = teamSofifaHTML.IndexOf("<tbody>");
                teamSofifaHTML = teamSofifaHTML.Substring(position + 1);
                position       = teamSofifaHTML.Substring(7).IndexOf("tbody>");
                teamSofifaHTML = teamSofifaHTML.Substring(0, position + 14);
                teamSofifaHTML = teamSofifaHTML.Replace("<tbody>", "</tbody>");
                teamSofifaHTML = "<" + teamSofifaHTML;

                htmlFinish = teamSofifaHTML.IndexOf("</tbody>");

                positonStartPlayerDetals = teamSofifaHTML.IndexOf("<tr");
                positonEndPlayerDetals   = teamSofifaHTML.IndexOf("</tr");
                playerDetailsHtml        = teamSofifaHTML.Substring(positonStartPlayerDetals, positonEndPlayerDetals);

                while (playerFound == true)
                {
                    playerDetailsSplitFromHtml(playerDetailsHtml, ref id, ref nickname, ref name, ref link, ref country, ref rating);

                    if (!String.IsNullOrEmpty(id) && id.All(char.IsDigit))
                    {
                        scorerDetails              = new ScorerDetails();
                        scorerDetails.id           = Convert.ToInt32(id);
                        scorerDetails.name         = name;
                        scorerDetails.nickname     = nickname;
                        scorerDetails.link         = link;
                        scorerDetails.country      = country;
                        scorerDetails.rating       = rating;
                        scorerDetails.sofifaTeamID = Convert.ToString(teamModel.teamSofifaID);
                        scorerDetails.teamID       = teamModel.id;

                        paramName  = new string[] { "pIdGoleador" };
                        paramValue = new string[] { id };
                        dt         = db.executePROC("spGetGoleadorByGoleador", paramName, paramValue);
                        if (dt.Rows.Count == 0)
                        {
                            paramName  = new string[] { "pIdGoleador", "pIdTime", "pNmGoleador", "pNmCompleto", "pDsLink", "pDsPais", "pIdSofifa", "pTipo", "pIdUsu" };
                            paramValue = new string[] { Convert.ToString(scorerDetails.id), Convert.ToString(scorerDetails.teamID), scorerDetails.nickname, scorerDetails.name, scorerDetails.link, scorerDetails.country, scorerDetails.sofifaTeamID, "H2H", "0" };
                            dt         = db.executePROC("spAddGoleador", paramName, paramValue);
                        }
                        listOfScorer.Add(scorerDetails);

                        positonStartPlayerDetals = positonEndPlayerDetals + 4;
                        positonEndPlayerDetals   = teamSofifaHTML.Length - positonStartPlayerDetals;
                        teamSofifaHTML           = teamSofifaHTML.Substring(positonStartPlayerDetals, positonEndPlayerDetals);

                        positonStartPlayerDetals = teamSofifaHTML.IndexOf("<tr");
                        positonEndPlayerDetals   = teamSofifaHTML.IndexOf("</tr");
                        if (positonStartPlayerDetals > -1 && positonEndPlayerDetals > -1)
                        {
                            playerDetailsHtml = teamSofifaHTML.Substring(positonStartPlayerDetals, positonEndPlayerDetals - positonStartPlayerDetals);
                        }
                        else
                        {
                            playerFound = false;
                        }
                    }
                    else
                    {
                        playerFound = false;
                    }
                }

                teamModel.listOfScorer  = listOfScorer;
                teamModel.returnMessage = "ModeratorSuccessfully";
            }
            catch (Exception ex)
            {
                teamModel.listOfScorer  = new List <ScorerDetails>();
                teamModel.returnMessage = "errorGetTeamDetails_" + ex.Message;
            }
            finally
            {
                scorerDetails = null;
                listOfScorer  = null;
                dt            = null;
            }
        }
示例#8
0
        public IHttpActionResult GetAll()
        {
            TeamDetailsModel        modelDetails = new TeamDetailsModel();
            TeamListViewModel       mainModel    = new TeamListViewModel();
            List <TeamDetailsModel> listOfModel  = new List <TeamDetailsModel>();
            DataTable dt = null;

            db.openConnection();


            try
            {
                paramName  = new string[] { };
                paramValue = new string[] { };
                dt         = db.executePROC("spGetAllTimesNoFilterCRUD", paramName, paramValue);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    modelDetails      = new TeamDetailsModel();
                    modelDetails.id   = Convert.ToInt32(dt.Rows[i]["ID_TIME"].ToString());
                    modelDetails.name = dt.Rows[i]["NM_TIME"].ToString();
                    if (!String.IsNullOrEmpty(dt.Rows[i]["IN_TIME_EXCLUIDO_TEMP_ATUAL"].ToString()))
                    {
                        modelDetails.teamDeleted = Convert.ToByte(dt.Rows[i]["IN_TIME_EXCLUIDO_TEMP_ATUAL"].ToString());
                    }
                    if (!String.IsNullOrEmpty(dt.Rows[i]["ID_TIME_SOFIFA"].ToString()))
                    {
                        modelDetails.teamSofifaID = Convert.ToInt32(dt.Rows[i]["ID_TIME_SOFIFA"].ToString());
                    }
                    if (!String.IsNullOrEmpty(dt.Rows[i]["IN_TIME_COM_IMAGEM"].ToString()))
                    {
                        modelDetails.hasImage = Convert.ToByte(dt.Rows[i]["IN_TIME_COM_IMAGEM"].ToString());
                    }
                    modelDetails.typeModeID    = Convert.ToUInt16(dt.Rows[i]["ID_TIPO_TIME"].ToString());
                    modelDetails.typeMode      = dt.Rows[i]["NM_Tipo_Time"].ToString();
                    modelDetails.teamSofifaURL = dt.Rows[i]["DS_URL_TIME"].ToString();
                    if (!String.IsNullOrEmpty(dt.Rows[i]["NM_Usuario"].ToString()))
                    {
                        modelDetails.userName = dt.Rows[i]["NM_Tecnico_FUT"].ToString();
                    }
                    listOfModel.Add(modelDetails);
                }

                mainModel.listOfTeam    = listOfModel;
                mainModel.returnMessage = "ModeratorSuccessfully";
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel));
            }
            catch (Exception ex)
            {
                mainModel               = new TeamListViewModel();
                mainModel.listOfTeam    = new List <TeamDetailsModel>();
                mainModel.returnMessage = "errorGetAll_" + ex.Message;
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel));
            }
            finally
            {
                db.closeConnection();
                modelDetails = null;
                mainModel    = null;
                listOfModel  = null;
                dt           = null;
            }
        }
示例#9
0
        public IHttpActionResult team(TeamDetailsModel model)
        {
            db.openConnection();
            DataTable dt           = null;
            var       objFunctions = new Commons.functions();

            try
            {
                if (model.actionUser.ToLower() == "dellcrud")
                {
                    paramName  = new string[] { "idTime" };
                    paramValue = new string[] { Convert.ToString(model.id) };
                    dt         = db.executePROC("spDeleteTime", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser.ToLower() == "save" && model.id > 0)
                {
                    paramName = new string[] { "pIdTime", "pNmTime", "pdsUrl", "pIdTipo", "pIdTimeSofifa", "pIdTecnico" };

                    paramValue = new string[] { Convert.ToString(model.id), model.name, model.teamSofifaURL,
                                                Convert.ToString(model.typeModeID), Convert.ToString(model.teamSofifaID),
                                                Convert.ToString(model.userID) };

                    dt = db.executePROC("spAddTime", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                }
                else if (model.actionUser.ToLower() == "save" && model.id == 0)
                {
                    paramName = new string[] { "pNmTime", "pdsUrl", "pIdTipo", "pIdTimeSofifa", "pIdTecnico" };

                    paramValue = new string[] { model.name, model.teamSofifaURL, Convert.ToString(model.typeModeID),
                                                Convert.ToString(model.teamSofifaID), Convert.ToString(model.userID) };


                    dt = db.executePROC("spAddTime", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                }
                else if (model.actionUser.ToLower() == "updateteamplayerslist")
                {
                    string getHtmlSofifaTeamPlayersList = objFunctions.getTeamSofifaHTML(model.teamSofifaURL);

                    processSofifaHTML(getHtmlSofifaTeamPlayersList, ref model);

                    return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                }
                else
                {
                    return(StatusCode(HttpStatusCode.NotAcceptable));
                }
            }
            catch (Exception ex)
            {
                model.returnMessage = "errorPostTeam_" + ex.Message;
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
            }
            finally
            {
                db.closeConnection();
                dt           = null;
                objFunctions = null;
            }
        }