Exemple #1
0
        //
        // GET: /Team/Create
        public ActionResult Create()
        {
            if (_sessionHelper.CurrentPlayer.Id == 0)
            {
                return(View("error"));
            }
            else
            {
                if (_teamBLL.TeamPlayerHasTeam(_sessionHelper.CurrentPlayer.Id))
                {
                    return(RedirectToAction("Profile", "Team"));
                }
                else
                {
                    ErrorView err = new ErrorView();

                    TeamCreateVM tcvm = new TeamCreateVM(err);

                    return(View("Create", "_Master2", tcvm));
                }
            }
        }
Exemple #2
0
        public ActionResult NewTeam()
        {
            ErrorView err = new ErrorView();

            TeamCreateVM tcvm = new TeamCreateVM(err);

            string name     = Request["txtName"];
            string tag      = Request["txtTag"];
            string page     = Request["txtPage"];
            string schedule = Request["selSchedule"];

            var response = Request["g-recaptcha-response"];
            //secret that was generated in key value pair
            const string secret = "6Lf7tAQTAAAAADkz1pwOVxH04e6WdLDTqRdmVDBf";

            var client = new WebClient();
            var reply  = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secret, response));

            var captchaResponse = JsonConvert.DeserializeObject <ReCaptchaValidator>(reply);

            if (captchaResponse.Success != "False")
            {
                if (!String.IsNullOrEmpty(name) && !String.IsNullOrEmpty(tag))
                {
                    if (!_teamBLL.TeamPlayerHasTeam(_sessionHelper.CurrentPlayer.Id))
                    {
                        if (!_teamBLL.TeamNameVerify(name))
                        {
                            if (!_teamBLL.TeamTagVerify(tag))
                            {
                                Team t = new Team(name, tag, page, schedule, DateTime.Now);

                                PlayerBLL p = new PlayerBLL();

                                t.Captain    = _sessionHelper.CurrentPlayer;
                                t.SubCaptain = new Player();

                                if (_teamBLL.TeamCreate(t, _sessionHelper.CurrentPlayer.Id))
                                {
                                    err.HasError = true;

                                    err.MsgError = "Time cadastrado com sucesso!";
                                }
                                else
                                {
                                    err.HasError = true;

                                    err.MsgError = "Erro ao criar o time";
                                }
                            }
                            else
                            {
                                err.HasError = true;

                                err.MsgError = "Esta tag já foi cadastrada no nosso sistema";
                            }
                        }
                        else
                        {
                            err.HasError = true;

                            err.MsgError = "Este nome já foi cadastrado no nosso sistema";
                        }
                    }
                    else
                    {
                        err.HasError = true;

                        err.MsgError = "Você já possui um time, danadin!";
                    }
                }
                else
                {
                    err.HasError = true;

                    err.MsgError = "Por favor preencha os campos corretamente";
                }
            }
            else
            {
                err.HasError = true;

                err.MsgError = "Captcha inválido";
            }

            return(View("Create", "_Master2", tcvm));
        }