예제 #1
0
        public ActionResult Comprar(DataCardVM MyModel)
        {
            try
            {
                using (var dbContext = new DBPortalEduDataContext())
                {
                    Tarjeta Card = new Tarjeta();
                    Card.tipotc     = MyModel.Tipotc;
                    Card.nombretc   = MyModel.Nombretc;
                    Card.bancotc    = MyModel.Bancotc;
                    Card.numerotc   = MyModel.Numerotc;
                    Card.ccv        = Convert.ToInt32(MyModel.CCV);
                    Card.mestc      = Convert.ToInt32(MyModel.Mestc);
                    Card.aniotc     = Convert.ToInt32(MyModel.Añotc);
                    Card.IdUsuariot = Convert.ToInt32(Sess.getSession("idUsuario"));
                    //dbContext.Tarjeta.InsertOnSubmit(Card);
                    //dbContext.SubmitChanges();

                    var List       = (from db in dbContext.Tarjeta where db.IdUsuariot == Card.IdUsuariot select db).ToList();
                    var LastFinded = List.LastOrDefault();
                    var Curso      = (from db in dbContext.Cursos where db.IdCurso == MyModel.idCurso select db).Single();

                    compras NuevaCompra = new compras();
                    NuevaCompra.fecha           = DateTime.Today;
                    NuevaCompra.valorcompra     = Curso.Costo;
                    NuevaCompra.IdUsuario       = Card.IdUsuariot;
                    NuevaCompra.idtarjetac      = LastFinded.idtarjeta;
                    NuevaCompra.idCursoComprado = Curso.IdCurso;
                    dbContext.compras.InsertOnSubmit(NuevaCompra);
                    dbContext.SubmitChanges();
                }
            }
            catch { }
            return(RedirectToAction("ListCarrito", "Principal"));
        }
예제 #2
0
        public ActionResult _PartialViewComprar(int idCurso)
        {
            DataCardVM MyCard = new DataCardVM();

            try
            {
                using (var dbContext = new DBPortalEduDataContext())
                {
                    Cursos Curs = (from db in dbContext.Cursos where db.IdCurso == idCurso select db).Single();
                    MyCard.idCurso = Curs.IdCurso;
                }
            }
            catch { }
            return(PartialView(MyCard));
        }