double GuardarPedidosutri(List <Order> _data) { try { int idVende = 0; foreach (var x in _data) { if (Context.Orders.Where(s => s.p_PEDIDO_MARDIS.Equals(x.p_PEDIDO_MARDIS)).Count() == 0) { Context.Orders.Add(x); Context.SaveChanges(); //Nutri if (x.Idaccount == 13) { IQueryable <Salesman> vendedor = Enumerable.Empty <Salesman>().AsQueryable(); vendedor = Context.Salesmans.Where(v => v.codigoDeValidacion == x.idVendedor && v.idaccount == x.Idaccount); if (vendedor.Count() > 0) { idVende = vendedor.First().id; } foreach (var detalle in x.pedidosItems) { IQueryable <Product> producto = Enumerable.Empty <Product>().AsQueryable(); Movil_Warenhouse movilw = new Movil_Warenhouse(); producto = Context.ProductOrders.Where(p => p.IdArticulo == detalle.idArticulo); movilw.BALANCE = detalle.cantidad; movilw.DESCRIPTION = "Venta"; movilw.IDVENDEDOR = vendedor.Count() > 0 ? vendedor.First().id : 0; movilw.IDPRODUCTO = producto.Count() > 0 ? producto.First().Id : 0; movilw.MOVEMENT = "-1"; //Guardar Context.Movil_Warenhouses.Add(movilw); Context.SaveChanges(); } } } } Context.Query <string>($@"EXEC dbo.sp_actualiza_movil_warehouse_app @idvendedor = {idVende}"); //db.PEDIDOS.Add(pEDIDOS); return(1.0); } catch (Exception ex) { return(-2.0); } }
public Boolean GuardarBodegaMovil(int warehouseid, int productid, int quantity, int entregadorid, int userid, string comment, int tipo) { try { int tipoIngreso = 1 * tipo; Movil_Warenhouse movil_Warenhouse = new Movil_Warenhouse(); movil_Warenhouse.IDVENDEDOR = entregadorid; movil_Warenhouse.BALANCE = quantity; movil_Warenhouse.DESCRIPTION = "INGRESO DE INVENTARIO APP"; movil_Warenhouse.MOVEMENT = tipoIngreso.ToString(); movil_Warenhouse.IDPRODUCTO = productid; movil_Warenhouse.COMMENT = comment; Context.Movil_Warenhouses.Add(movil_Warenhouse); Context.SaveChanges(); int tipoIngresoWarenhouse = -1 * tipo; Central_Warenhouse central_Warenhouse = new Central_Warenhouse(); central_Warenhouse.IDDISTRIBUTOR = warehouseid; central_Warenhouse.BALANCE = quantity; central_Warenhouse.DESCRIPTION = "INGRESO DE INVENTARIO APP"; central_Warenhouse.MOVEMENT = tipoIngresoWarenhouse.ToString(); central_Warenhouse.IDPRODUCTO = productid; Context.Central_Warenhouses.Add(central_Warenhouse); Context.SaveChanges(); var _dataTable = Context.Query <List <int> >($@"EXEC dbo.sp_actuaiza_movil_warehouse_resume_APP @idvendedor ={entregadorid} ,@idproducto = { productid} ,@iddistribuidor ={warehouseid}"); return(true); } catch (Exception ex) { throw; return(false); } }