private ListaDePrecio EntityAListaDePrecio(Entity entity) { ListaDePrecio lista = new ListaDePrecio(); lista.Name = entity.GetStringValue("name"); lista.Id = entity.Id; lista.TransactionCurrencyId = entity.GetEntityReferenceId("transactioncurrencyid"); return(lista); }
public IList <ListaDePrecio> ObtenerListasDePrecios(ListaDePrecio listaDePrecio) { DbParameter[] parameters = { new OAParameter { ParameterName = "@CODE_PRICE_LIST", Value = listaDePrecio.CODE_PRICE_LIST } }; return(BaseDeDatosServicio.ExecuteQuery <ListaDePrecio>("SWIFT_SP_GET_PRICE_LIST", CommandType.StoredProcedure, parameters).ToList()); }
public Operacion ValidarPrecioSkuAsignadoAClienteYSkuEnWarehouseDeUsuario(ListaDePrecio listaDePrecio) { BaseDeDatosServicio.BeginTransaction(); try { DbParameter[] parameters = { new OAParameter { ParameterName = "@CODE_SKU", Value = listaDePrecio.CODE_SKU }, new OAParameter { ParameterName = "@CODE_CUSTOMER", Value = listaDePrecio.CODE_CUSTOMER }, new OAParameter { ParameterName = "@LOGIN", Value = listaDePrecio.LOGIN } }; var op = BaseDeDatosServicio.ExecuteQuery <Operacion>("SWIFT_VALIDATE_SKU_PRICE_ASIGNED_TO_CUSTMR_AND_WH_USER", CommandType.StoredProcedure, parameters)[0]; BaseDeDatosServicio.Commit(); return(op); } catch (DbException e) { BaseDeDatosServicio.Rollback(); return(new Operacion { Codigo = e.ErrorCode, Mensaje = e.Message, Resultado = Tipos.ResultadoOperacionTipo.Error }); } catch (Exception ex) { BaseDeDatosServicio.Rollback(); return(new Operacion { Codigo = -1, Mensaje = ex.Message, Resultado = Tipos.ResultadoOperacionTipo.Error }); } }
private Oportunidad BuildOportunidad(Entity entity, ListaDePrecio lista) { string nombre = entity.GetStringValue("fullname"); Oportunidad opportunity = new Oportunidad { Name = $"OPT-{nombre}", OrderType = OrderType.BasadoEnTrabajo, ContactId = new EntityReference("contact", entity.Id), BudgetAmount = 1000, EstimatedValue = 10000, EstimatedCloseDate = DateTime.Now.AddMonths(1), PriceList = new EntityReference("pricelevel", lista.Id), TransactionCurrencyId = new EntityReference("transactioncurrency", lista.TransactionCurrencyId) }; return(opportunity); }
public IList <SkuParaVenta> ObtenerSkusPorListaDePrecio(ListaDePrecio listaDePrecio) { DbParameter[] parameters = { new OAParameter { ParameterName = "@LOGIN", Value = listaDePrecio.LOGIN } , new OAParameter { ParameterName = "@CODE_PRICE_LIST", Value = listaDePrecio.CODE_PRICE_LIST } }; return(BaseDeDatosServicio.ExecuteQuery <SkuParaVenta>("SWIFT_SP_GET_PRESALE_SKU_BY_PRICE_LIST", CommandType.StoredProcedure, parameters).ToList()); }
public void Execute(IServiceProvider serviceProvider) { try { ServerConnection cnx = new ServerConnection(serviceProvider); CrmRepository crmRepository = new CrmRepository(cnx); Entity entity = (Entity)cnx.context.InputParameters["Target"]; if (!ValidarContexto(entity, cnx)) { return; } ListaDePrecio listaDePrecio = crmRepository.ObtenerListaDePrecios().Find(l => l.Name == "Retail"); Oportunidad opportunity = BuildOportunidad(entity, listaDePrecio); crmRepository.CrearOportunidad(opportunity); } catch (Exception e) { throw new InvalidPluginExecutionException(); } }
public void CreaLaOportunidad() { // Arrange ListaDePrecio listaDePrecio = _crmRepository.ObtenerListaDePrecios().Find(l => l.Name == "Retail"); Oportunidad op = new Oportunidad { Name = $"OPT-Miguel", OrderType = OrderType.BasadoEnTrabajo, ContactId = new EntityReference("contact", new Guid("DFEA0607-1DD2-E811-A963-000D3A3AB6B4")), BudgetAmount = 1000, EstimatedValue = 10000, EstimatedCloseDate = DateTime.Now.AddMonths(1), PriceList = new EntityReference("pricelevel", listaDePrecio.Id), TransactionCurrencyId = new EntityReference("transactioncurrency", listaDePrecio.TransactionCurrencyId) }; // Act Guid result = _crmRepository.CrearOportunidad(op); // Assert Assert.AreNotEqual(default(Guid), result); }