public ActionResult Salvar(Team objeto, bool editar = false)
        {
            try
            {
                Team team;

                if (editar)
                {
                    db.Entry(objeto).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    team = new Team()
                    {
                        Description = Request.Form.Get("description")
                    };

                    db.Team.Add(team);
                    db.SaveChanges();

                    this.FlashSuccess("Time adicionado com sucesso.");
                }
            }
            catch (Exception ex)
            {
                //if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.ToString().Contains("AK_TDM_Descricao"))
                //    this.FlashError("Já existe uma TDM com essa descrição.");
                //else
                //    this.FlashError(ex.Message);
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Salvar(Payment objeto, bool editar = false)
        {
            try
            {
                Payment pagamento;

                if (editar)
                {
                    db.Entry(objeto).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    pagamento = new Payment()
                    {
                    };

                    db.Payment.Add(pagamento);
                    db.SaveChanges();

                    this.FlashSuccess("Jogador adicionado com sucesso.");
                }
            }
            catch (Exception ex)
            {
                //if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.ToString().Contains("AK_TDM_Descricao"))
                //    this.FlashError("Já existe uma TDM com essa descrição.");
                //else
                //    this.FlashError(ex.Message);
            }

            return(RedirectToAction("Index"));
        }
示例#3
0
        public ActionResult Salvar(Player objeto, bool editar = false)
        {
            try
            {
                Player player;

                if (editar)
                {
                    db.Entry(objeto).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    player = new Player()
                    {
                        Name             = Request.Form.Get("name"),
                        Address          = Request.Form.Get("address"),
                        Cpf              = Request.Form.Get("cpf"),
                        DateOfBorn       = Request.Form.Get("DateOfBorn"),
                        Height           = Request.Form.Get("height"),
                        Weight           = Request.Form.Get("weight"),
                        Nickname         = Request.Form.Get("nickname"),
                        ProfileFacebook  = Request.Form.Get("profileFacebook"),
                        ProfileInstagram = Request.Form.Get("profileInstagram"),
                        Rg        = Request.Form.Get("rg"),
                        Telephone = Request.Form.Get("telephone"),
                        IdTeamFK  = Int32.Parse(Request.Form.Get("times"))
                    };

                    db.Player.Add(player);
                    db.SaveChanges();

                    this.FlashSuccess("Jogador adicionado com sucesso.");
                }
            }
            catch (Exception ex)
            {
                //if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.ToString().Contains("AK_TDM_Descricao"))
                //    this.FlashError("Já existe uma TDM com essa descrição.");
                //else
                //    this.FlashError(ex.Message);
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Salvar(SystemUser objeto, bool editar = false)
        {
            try
            {
                SystemUser usuario;

                if (editar)
                {
                    db.Entry(objeto).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    usuario = new SystemUser()
                    {
                        Name            = objeto.Name,
                        Login           = objeto.Login,
                        Password        = objeto.Password,
                        DataInclusao    = DateTime.Now,
                        DataAtualizacao = DateTime.Now,
                    };

                    db.SystemUser.Add(usuario);
                    db.SaveChanges();

                    this.FlashSuccess("Usuário adicionado com sucesso.");
                }
            }
            catch (Exception ex)
            {
                //if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.ToString().Contains("AK_TDM_Descricao"))
                //    this.FlashError("Já existe uma TDM com essa descrição.");
                //else
                //    this.FlashError(ex.Message);
            }

            return(RedirectToAction("Index"));
        }