Example #1
0
        public void Actualizar(bizVenta objeto)
        {
            Mapeador.AutoMapperORMConfiguration.Configure();
            var ORM = Mapper.Map <bizVenta, Venta>(objeto);

            ORM.ChangedBy = objeto.UserId;
            ORM.ChangedOn = DateTime.Now;

            contexto.Entry(ORM).State = System.Data.Entity.EntityState.Modified;
        }
Example #2
0
        public void Insertar(bizVenta objeto)
        {
            Mapeador.AutoMapperORMConfiguration.Configure();
            var ORM = Mapper.Map <bizVenta, Venta>(objeto);

            ORM.CreatedOn = DateTime.Now;
            ORM.CreatedBy = objeto.UserId;
            ORM.UserId    = objeto.UserId;

            using (var t = contexto.Database.BeginTransaction())
            {
                try
                {
                    contexto.Ventas.Add(ORM);
                    contexto.SaveChanges();

                    t.Commit();
                }
                catch (Exception)
                {
                    t.Rollback();
                }
            }
        }