public ActionResult Create([Bind(Include = "InvestimentoId,Descricao,QuantidadeDisponivel,Valor,QuantidadeVendida")] Investimento investimento) { if (ModelState.IsValid) { db.Investimento.Add(investimento); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(investimento)); }
public ActionResult Create([Bind(Include = "MoedaId,Nome,Apelido,Preco,Saldo")] Moeda moeda) { if (ModelState.IsValid) { db.Moeda.Add(moeda); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(moeda)); }
public ActionResult Create([Bind(Include = "UsuarioId,Nome,Login,Senha,Email,Cpf")] Usuario usuario) { if (ModelState.IsValid) { db.Usuarios.Add(usuario); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(usuario)); }
public ActionResult Create([Bind(Include = "PostId,Titulo,Conteudo")] Post post) { if (ModelState.IsValid) { post.DataPost = DateTime.Now; db.Post.Add(post); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(post)); }
public ActionResult Create([Bind(Include = "TransacaoId,MoedaId,Quantidade")] Transacao transacao) { if (ModelState.IsValid) { transacao.DataTransacao = DateTime.Now; transacao.UsuarioId = int.Parse(Session["Id"].ToString()); db.Transacao.Add(transacao); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MoedaId = new SelectList(db.Moeda, "MoedaId", "Nome", transacao.MoedaId); return(View(transacao)); }
public ActionResult Create([Bind(Include = "CompraInvestimentoId,DataCompra,Quantidade,UsuarioId,InvestimentoId")] CompraInvestimento compraInvestimento, Investimento investimento) { if (ModelState.IsValid) { if (Session["Id"] != null) { compraInvestimento.UsuarioId = Convert.ToInt32(Session["Id"]); } compraInvestimento.DataCompra = DateTime.Now; db.CompraInvestimento.Add(compraInvestimento); //if(compraInvestimento.Quantidade <= investimento.QuantidadeDisponivel) //{ db.SaveChanges(); return(RedirectToAction("Index")); //} //return RedirectToAction("Create", "CompraInvestimento"); } // ViewBag.UsuarioId = new SelectList(db.Usuarios, "UsuarioId", "Nome", compraInvestimento.UsuarioId); ViewBag.InvestimentoId = new SelectList(db.Investimento, "InvestimentoId", "Descricao", compraInvestimento.InvestimentoId); return(View(compraInvestimento)); }
public ActionResult Registrar(Usuario usuario) { if (ModelState.IsValid) { using (CryptoCenterContext db = new CryptoCenterContext()) { db.Usuarios.Add(usuario); db.SaveChanges(); } ModelState.Clear(); ViewBag.Message = usuario.Nome + " registrado com sucesso!"; } return(View()); }