コード例 #1
0
        public JResult InsCliente(ClienteViewModel model)
        {
            try
            {
                FACT_CLIENTE dbItem = new FACT_CLIENTE
                {
                    Id              = model.Id,
                    Documento       = model.Documento.ToUpper(),
                    Nombres         = model.Nombres.ToUpper(),
                    FechaNacimiento = model.FechaNacimiento,
                    Telefono        = model.Telefono,
                    Direccion       = model.Direccion.ToUpper(),
                    Estregistro     = 1,
                };

                db.FACT_CLIENTE.Attach(dbItem);
                db.Entry(dbItem).State = EntityState.Added;
                db.SaveChanges();
                model.Id          = dbItem.Id;
                model.Estregistro = 1;
                jresult.Data      = model;

                #region Salida Generica OK
                return(jresult.SetOk("Registro creado correctamente"));

                #endregion
            }
            #region Salida generica para errores
            catch (Exception ex)
            {
                return(jresult.SetError(ex, "Error registrando datos", this.GetType().Name));
            }
            #endregion
        }
コード例 #2
0
        public JResult InsInventario(InventarioViewModel model)
        {
            try
            {
                FACT_INVENTARIO dbItem = new FACT_INVENTARIO
                {
                    Id          = model.Id,
                    ProductoId  = model.ProductoId,
                    Existencias = model.Existencias,
                    Estregistro = 1,
                };

                db.FACT_INVENTARIO.Attach(dbItem);
                db.Entry(dbItem).State = EntityState.Added;
                db.SaveChanges();
                model.Id          = dbItem.Id;
                model.Estregistro = 1;
                jresult.Data      = model;

                #region Salida Generica OK
                return(jresult.SetOk("Registro creado correctamente"));

                #endregion
            }
            #region Salida generica para errores
            catch (Exception ex)
            {
                return(jresult.SetError(ex, "Error registrando datos", this.GetType().Name));
            }
            #endregion
        }
コード例 #3
0
        public JResult InsProducto(ProductoViewModel model)
        {
            try
            {
                FACT_PRODUCTO dbItem = new FACT_PRODUCTO
                {
                    Id          = model.Id,
                    Codigo      = model.Codigo.ToUpper(),
                    Nombre      = model.Nombre.ToUpper(),
                    Valor       = model.Valor,
                    Estregistro = 1
                };

                db.FACT_PRODUCTO.Attach(dbItem);
                db.Entry(dbItem).State = EntityState.Added;
                db.SaveChanges();
                model.Id          = dbItem.Id;
                model.Estregistro = 1;
                jresult.Data      = model;

                #region Salida Generica OK
                return(jresult.SetOk("Registro creado correctamente"));

                #endregion
            }
            #region Salida generica para errores
            catch (Exception ex)
            {
                return(jresult.SetError(ex, "Error registrando datos", this.GetType().Name));
            }
            #endregion
        }
コード例 #4
0
        public JResult InsFactura(FacturaViewModel model)
        {
            try
            {
                FACT_FACTURA dbItem = new FACT_FACTURA
                {
                    Id          = model.Id,
                    ClienteId   = model.ClienteId,
                    Fecha       = model.Fecha, //utilidades.ObtenerFechaDesdeString(model.Fecha),
                    Total       = model.Total,
                    Estregistro = 1,
                };

                db.FACT_FACTURA.Attach(dbItem);
                db.Entry(dbItem).State = EntityState.Added;
                db.SaveChanges();
                model.Id          = dbItem.Id;
                model.Estregistro = 1;
                jresult.Data      = model;

                #region Salida Generica OK
                return(jresult.SetOk("Registro creado correctamente"));

                #endregion
            }
            #region Salida generica para errores
            catch (Exception ex)
            {
                return(jresult.SetError(ex, "Error registrando datos", this.GetType().Name));
            }
            #endregion
        }
コード例 #5
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (_context.Entry(entityToDelete).State == EntityState.Detached)
     {
         _dbSet.Attach(entityToDelete);
     }
     _dbSet.Remove(entityToDelete);
 }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "PK_Id,Name")] tblGroups tblGroups)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblGroups).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblGroups));
 }
コード例 #7
0
        public JResult InsFacturaDetalle(FacturaDetalleViewModel model)
        {
            try
            {
                ProductoBL productoBL = new ProductoBL();
                var        producto   = productoBL.GetProducto(model.InventarioId);

                FACT_FACTURA_DETALLE dbItem = new FACT_FACTURA_DETALLE
                {
                    Id           = model.Id,
                    FacturaId    = model.FacturaId,
                    InventarioId = model.InventarioId,
                    Cant         = model.Cant,
                    Subtotal     = producto.Data.Valor * model.Cant,
                    Estregistro  = 1,
                };

                db.FACT_FACTURA_DETALLE.Attach(dbItem);
                db.Entry(dbItem).State = EntityState.Added;
                db.SaveChanges();

                var result = UpdTotalFactura(model.FacturaId);
                if (!result.Success)
                {
                    return(jresult.SetError(null, "Error actualizando total factura", this.GetType().Name));
                }

                model.Id          = dbItem.Id;
                model.Estregistro = 1;
                jresult.Data      = model;

                #region Salida Generica OK
                return(jresult.SetOk("Registro creado correctamente"));

                #endregion
            }
            #region Salida generica para errores
            catch (Exception ex)
            {
                return(jresult.SetError(ex, "Error registrando datos", this.GetType().Name));
            }
            #endregion
        }
コード例 #8
0
ファイル: EntryManager.cs プロジェクト: ejricahuerta/Diary
        public Entryvm EditEntry(Entryvm entry)
        {
            var user    = m.User.SingleOrDefault(x => x.Name == entry.UserName);
            var archive = m.Archives.SingleOrDefault(x => x.DateAdded.Month == entry.DateAdded.Month);
            var o       = m.Entries.Find(entry.Id);

            o.Archive = archive;
            o.User    = user;
            if (o == null)
            {
                return(null);
            }
            else
            {
                m.Entry(o).CurrentValues.SetValues(entry);
                m.SaveChanges();
            }
            return(Mapper.Map <Entry, Entryvm>(o));
        }