public ResultadoPrima GetPrimaCuota(int table, int cotizacionID) { IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { switch (table) { case (int)enumTableCotizacion.EqContratista: return(activeContext.ExecuteQuery <ResultadoPrima>("select isnull(Cuota,0) Cuota, isnull(Prima,0) Prima from Cotizar.bk_te_CotizacionEqContratista where cotizacionID = " + cotizacionID.ToString(), null).ToList()[0]); case (int)enumTableCotizacion.RCEqContratista: return(activeContext.ExecuteQuery <ResultadoPrima>("select isnull(Cuota,0) Cuota, isnull(Prima,0) Prima from Cotizar.bk_te_CotizacionRCEqContratista where cotizacionID = " + cotizacionID.ToString(), null).ToList()[0]); case (int)enumTableCotizacion.RCActInm: return(activeContext.ExecuteQuery <ResultadoPrima>("select isnull(Cuota,0) Cuota, isnull(Prima,0) Prima from Cotizar.bk_te_CotizacionRCActInm where cotizacionID = " + cotizacionID.ToString(), null).ToList()[0]); default: return(null); } } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public List <CotizacionCobertura> FindCotizacionCoberturas(ISpecification <CotizacionCobertura> specification) { //validate specification if (specification == (ISpecification <CotizacionCobertura>)null) { throw new ArgumentNullException("CotizacionCobertura specification"); } IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository return(activeContext.CotizacionCoberturas .Where(specification.SatisfiedBy()) .Include(j => j.bk_tc_Cobertura) .ToList()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public Usuario FindUser(ISpecification <Usuario> specification) { //validate specification if (specification == (ISpecification <Usuario>)null) { throw new ArgumentNullException("User specification"); } IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository return(activeContext.Usuarios .Where(specification.SatisfiedBy()) .Include(x => x.bk_tr_UsuarioSubLinea) .Include("bk_tr_UsuarioSubLinea.bk_tc_SubLineaNegocio") .SingleOrDefault()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public Cotizacion FindCotizacionRC(int cotizacionID) { IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository return(activeContext.Cotizaciones .Where(x => x.CotizacionID == cotizacionID) .Include(p => p.bk_te_CotizacionRCActInm) //.Include(p => p.bk_te_CotizacionRCProducto) .Include(p => p.bk_te_CotizacionRCTrabajoTerm) .Include(p => p.bk_te_CotizacionRCTaller) .Include(p => p.bk_te_CotizacionRCEstacionamiento) .Include(p => p.bk_te_CotizacionRCVehiculoExc) .Include(p => p.bk_te_CotizacionRCConstruccion) .Include(p => p.bk_te_CotizacionRCHoteleria) .Include(p => p.bk_te_CotizacionDeducible) .Include(p => p.bk_te_CotizacionRCAdicional) .SingleOrDefault()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public Cotizacion FindCotizacion(ISpecification <Cotizacion> specification) { //validate specification if (specification == (ISpecification <Cotizacion>)null) { throw new ArgumentNullException("Cotizacion specification"); } IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository return(activeContext.Cotizaciones .Where(specification.SatisfiedBy()) .Include(j => j.bk_tc_Asegurado) .Include(j => j.bk_tr_CotizacionSubLineaNegocio) .Include(j => j.bk_tr_CotizacionTipoCobertura) .Include(j => j.bk_tc_Contacto) .Include("bk_tr_CotizacionSubLineaNegocio.bk_tc_SubLineaNegocio") .Include("bk_tr_CotizacionTipoCobertura.bk_tc_TipoCobertura") .SingleOrDefault()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.Domain.MainModule.Customers.ICustomerRepository"/> /// </summary> /// <param name="specification"><see cref="Microsoft.Samples.NLayerApp.Domain.MainModule.Customers.ICustomerRepository"/></param> /// <returns>Customer that match <paramref name="specification"/></returns> public Customer FindCustomer(ISpecification <Customer> specification) { //validate specification if (specification == (ISpecification <Customer>)null) { throw new ArgumentNullException("specification"); } IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository return(activeContext.Customers .Include(c => c.CustomerPicture) .Where(specification.SatisfiedBy()) .SingleOrDefault()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.Domain.MainModule.Orders.IOrderRepository"/> /// </summary> /// <param name="customerCode"><see cref="Microsoft.Samples.NLayerApp.Domain.MainModule.Orders.IOrderRepository"/></param> /// <returns><see cref="Microsoft.Samples.NLayerApp.Domain.MainModule.Orders.IOrderRepository"/></returns> public IEnumerable <Order> FindOrdersByCustomerCode(string customerCode) { if (String.IsNullOrEmpty(customerCode) || String.IsNullOrWhiteSpace(customerCode) ) { throw new ArgumentNullException("customerCode"); } // // Other valid query for this case is base.GetFilteredElements(o => o.Customer.CustomerCode == customerCode); // In this case also you can use OrderFromCustomerSpecification but for sample purposed this method // is created using linq to entities implementation // IMainModuleUnitOfWork actualContext = base.UnitOfWork as IMainModuleUnitOfWork; if (actualContext != null) { return((from order in actualContext.Orders where order.Customer.CustomerCode == customerCode select order).AsEnumerable()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public Asegurado FindAsegurado(ISpecification <Asegurado> specification) { //validate specification if (specification == (ISpecification <Asegurado>)null) { throw new ArgumentNullException("Asegurado specification"); } IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository return(activeContext.Asegurados .Where(specification.SatisfiedBy()) .Include(j => j.bk_tc_Colonia) .Include(j => j.bk_tc_EstadoCivil) .Include(j => j.bk_tc_TipoPersona) .Include(j => j.bk_tc_TipoTelefono) .Include("bk_tc_Colonia.bk_tc_Ciudad") .Include("bk_tc_Colonia.bk_tc_Municipio") .Include("bk_tc_Colonia.bk_tc_Municipio.bk_tc_Estado") .Include("bk_tc_Colonia.bk_tc_Municipio.bk_tc_Estado.bk_tc_Pais") .SingleOrDefault()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public List <Asegurado> FindAseguradobyFiltro(ISpecification <Asegurado> specification) { //validate specification if (specification == (ISpecification <Asegurado>)null) { throw new ArgumentNullException("Asegurado specification"); } IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository return(activeContext.Asegurados .Where(specification.SatisfiedBy()) .ToList()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public workflow FindWorkFlow(ISpecification <workflow> specification) { //validate specification if (specification == (ISpecification <workflow>)null) { throw new ArgumentNullException("WorkFlow specification"); } IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository return(activeContext.workflows .Where(specification.SatisfiedBy()) .SingleOrDefault()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public List <Ubicacion> FindUbicaciones(ISpecification <Ubicacion> specification, int nroPagina, int tamaño) { //validate specification if (specification == (ISpecification <Ubicacion>)null) { throw new ArgumentNullException("Ubicacion specification"); } IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository return(activeContext.Ubicaciones .Where(specification.SatisfiedBy()) .Include(j => j.bk_tc_Colonia) .OrderBy(c => c.UbicacionID) .Skip(nroPagina * tamaño) .Take(tamaño) .ToList()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public Cotizacion FindCotizacionEQbyID(int cotizacionID) { Cotizacion cot = new Cotizacion(); IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository //cot.bk_te_CotizacionEqContratista = activeContext.CotizacionEqContratistas // .Where(x => x.CotizacionID == cotizacionID) // .SingleOrDefault(); //cot.bk_te_CotizacionRCEqContratista = activeContext.CotizacionRCEqContratistas // .Where(x => x.CotizacionID == cotizacionID) // .SingleOrDefault(); return(activeContext.Cotizaciones .Where(x => x.CotizacionID == cotizacionID) .Include(x => x.bk_te_CotizacionEqContratista) .Include(x => x.bk_te_CotizacionRCEqContratista) .SingleOrDefault()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.Domain.MainModule.BankAccounts.IBankAccountRepository"/> /// </summary> /// <param name="pageIndex"> <see cref="Microsoft.Samples.NLayerApp.Domain.MainModule.BankAccounts.IBankAccountRepository"/></param> /// <param name="pageCount"> <see cref="Microsoft.Samples.NLayerApp.Domain.MainModule.BankAccounts.IBankAccountRepository"/></param> /// <returns> <see cref="Microsoft.Samples.NLayerApp.Domain.MainModule.BankAccounts.IBankAccountRepository"/></returns> public IEnumerable <BankAccount> FindPagedBankAccountsWithTransferInformation(int pageIndex, int pageCount) { if (pageIndex < 0) { throw new ArgumentException(Resources.Messages.exception_InvalidPageIndex, "pageIndex"); } if (pageCount <= 0) { throw new ArgumentException(Resources.Messages.exception_InvalidPageCount, "pageCount"); } IMainModuleUnitOfWork context = this.UnitOfWork as IMainModuleUnitOfWork; if (context != null) { return((from ba in context.BankAccounts.Include(ba => ba.BankTransfersFromThis) orderby ba.BankAccountNumber select ba).AsEnumerable()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public void FindBanksAccounts_Invoke_NullSpecThrowNewArgumentNullException_Test() { //Arrange IMainModuleUnitOfWork context = this.GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); BankAccountRepository repository = new BankAccountRepository(context, traceManager); repository.GetBySpec(null); }
public void FindCustomer_Invoke_NullSpecThrowNewArgumentNullException_Test() { //Arrange IMainModuleUnitOfWork context = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); ICustomerRepository repository = new CustomerRepository(context, traceManager); //Act repository.FindCustomer(null); }
public void FindOrdersByCustomerDateRangeSpecification_NullSpecThrowNewArgumentNullException_Test() { //Arrange IMainModuleUnitOfWork context = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); IOrderRepository repository = new OrderRepository(context, traceManager); //Act IEnumerable <Order> orders = repository.GetBySpec(null); }
public void FindOrdersByDate_NullSpecThrowNewArgumentNullException_Test() { //Arrange IMainModuleUnitOfWork context = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); IOrderRepository repository = new OrderRepository(context, traceManager); //Act repository.GetBySpec(null); }
public void FindProductByProductInformation_NullSpecThrowNewArgumentNullException_Test() { //Arrange IMainModuleUnitOfWork context = this.GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); ProductRepository repository = new ProductRepository(context, traceManager); //Act repository.GetBySpec(null); }
public void FindOrdersByCustomerCode_Test() { //Arrange IMainModuleUnitOfWork context = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); IOrderRepository repository = new OrderRepository(context, traceManager); //Act IEnumerable <Order> orders = repository.FindOrdersByCustomerCode(customerCode); //Assert Assert.IsNotNull(orders); }
public void FindBankAccount_Invoke_NullSpecThrowArgumentNullException_Test() { //Arrange IMainModuleUnitOfWork context = this.GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); BankAccountRepository repository = new BankAccountRepository(context, traceManager); //Act BankAccount actual; actual = repository.GetBySpec(null) .SingleOrDefault(); }
public void FindPagedCusomer_Test() { //Arrage IMainModuleUnitOfWork context = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); ICustomerRepository repository = new CustomerRepository(context, traceManager); //Act var result = repository.GetPagedElements(0, 2, c => c.CustomerId, true).ToList(); Assert.IsTrue(result != null); Assert.IsTrue(result.Count == 2); }
public Cotizacion FindCotizacionDiversos(int cotizacionID) { IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { //perform operation in this repository Cotizacion parent = activeContext.Cotizaciones .Where(x => x.CotizacionID == cotizacionID) .Include(p => p.bk_te_CotizacionAnuncio) .Include(p => p.bk_te_CotizacionCristal) .Include(p => p.bk_te_CotizacionRobo) .Include(p => p.bk_te_CotizacionDinVal) .Include(p => p.bk_te_CotizacionCaldera) .Include(p => p.bk_te_CotizacionCalderaPC) .Include(p => p.bk_te_CotizacionRotMaq) .Include(p => p.bk_te_CotizacionRotMaqPC) .Include(p => p.bk_te_CotizacionEqContratista) .Include(p => p.bk_te_CotizacionEqElec) .Include(p => p.bk_te_CotizacionEqElecPortExt) .Include(p => p.bk_te_CotizacionEqElecCostoOper) .Include(p => p.bk_te_CotizacionEqElecMovil) .Include(p => p.bk_te_CotizacionRCEqContratista) .Include(p => p.bk_tw_EqContratistaEquipo) .Include(p => p.bk_te_CotizacionDeducible) .Include("bk_te_CotizacionDeducible.bk_tc_Tarifa") .Include(p => p.bk_tc_Moneda) .SingleOrDefault(); //parent.bk_te_CotizacionDeducible = parent.bk_te_CotizacionDeducible.OrderBy(x => x.bk_tc_Tarifa.orden); var sorted = parent.bk_te_CotizacionDeducible.OrderBy(x => x.bk_tc_Tarifa.orden).ToList(); parent.bk_te_CotizacionDeducible.Clear(); for (int i = 0; i < sorted.Count(); i++) { parent.bk_te_CotizacionDeducible.Add(sorted[i]); } return(parent); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public void FindOrdersByDate_MaxMinDateSpec_Test() { //Arrange IMainModuleUnitOfWork context = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); IOrderRepository repository = new OrderRepository(context, traceManager); OrderDateSpecification ordersSpec = new OrderDateSpecification(DateTime.MinValue, DateTime.MaxValue); //Act IEnumerable <Order> orders = repository.GetBySpec(ordersSpec); //Asser Assert.IsNotNull(orders); Assert.IsTrue(orders.Count() > 0); }
public void FindOrdersByCustomerDateRangeSpecification_Invoke_Test() { //Arrange IMainModuleUnitOfWork context = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); IOrderRepository repository = new OrderRepository(context, traceManager); OrderFromCustomerDateRangeSpecification spec = new OrderFromCustomerDateRangeSpecification(1, new DateTime(2008, 12, 1), new DateTime(2009, 2, 1)); //Act IEnumerable <Order> orders = repository.GetBySpec(spec); //Assert Assert.IsNotNull(orders); }
public int execUpdateCotizacionEq(int cotizacionID, string equiposXML, string nombreArchivo) { IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { return(activeContext.ExecuteCommand("exec bk_sp_InsertCotizacionEqContratistaEquipo @CotizacionID={0}, @datosEquipos={1}, @fileName = {2}", cotizacionID, equiposXML, nombreArchivo)); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public void FindOrdersByShippingInfo_NullDataInShippSpec_Test() { //Arrange IMainModuleUnitOfWork context = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); IOrderRepository repository = new OrderRepository(context, traceManager); OrderShippingSpecification spec = new OrderShippingSpecification(null, null, null, null); //Act IEnumerable <Order> orders = repository.GetBySpec(spec); //Assert Assert.IsNotNull(orders); Assert.IsTrue(orders.Count() > 0); }
public int execUpdateCotizacionCoberturaUbicacion(int cotizacionID) { IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { return(activeContext.ExecuteCommand("exec bk_sp_UpdateCotizacionCoberturaUbicacion @CotizacionID={0}", cotizacionID)); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public List <string> GetMensajeLimiteReaseguro(int cotizacionID) { IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { return(activeContext.ExecuteQuery <string>("exec bk_sp_SelectValLimiteReaseguro @cotizacionID = {0}", cotizacionID).ToList()); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public double execSelectGastosAdmCalculado(int cotizacionID, double cuotaDeseada) { IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { return(activeContext.ExecuteQuery <double>("exec bk_sp_SelectGactosAdmCalculado @CotizacionID={0}, @cuotaDeseada ={1}", cotizacionID, cuotaDeseada).ToList()[0]); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }
public int execDeleteCotizacionEqContratistaEquipo() { IMainModuleUnitOfWork activeContext = this.UnitOfWork as IMainModuleUnitOfWork; if (activeContext != null) { return(activeContext.ExecuteCommand("exec bk_sp_DeleteEqContratistaEquipo", null)); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, Messages.exception_InvalidStoreContext, this.GetType().Name)); } }