/// <summary>
 /// 
 /// </summary>
 /// <param name="Broker"></param>
 /// <returns></returns>
 public static int Create(Promociones Broker)
 {
     using (MsSqlFacade<Promociones, PromocionesMapper> facade = new MsSqlFacade<Promociones, PromocionesMapper>())
     {
         //// we use the Collection to build the broker entity on an abstract phase to manage it as a all
         return facade.Create(Broker);
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="cliente"></param>
 /// <returns></returns>
 public static int CreateSocialCliente(SocialClientes cliente)
 {
     try
     {
         using (MsSqlFacade<SocialClientes, SocialClientesMapper> facade = new MsSqlFacade<SocialClientes, SocialClientesMapper>())
         {
             return facade.Create(cliente);
         }
     }
     catch
     {
         /// in case that fails, we give an empty list
         return -1;
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public static int FollowMercante(int Mercante, int Cliente)
 {
     try
     {
         using (MsSqlFacade<ClientesMercantes, ClientesMercantesMapper> facade = new MsSqlFacade<ClientesMercantes, ClientesMercantesMapper>())
         {
             // we now select all the promotions that are active but we make it into a linear research
             // thus is not woow efficient is enought for it's end. 
             return facade.Create(new ClientesMercantes() { Cliente = Cliente, Mercante = Mercante });
         }
     }
     catch
     {
         /// in case that fails, we give an empty list
         return 0;
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="broker"></param>
 /// <returns></returns>
 public static int CreateCategoriasClientes(data.entities.CategoriasClientes broker)
 {
     try
     {
         using (MsSqlFacade<CategoriasClientes, CategoriasClientesMapper> facade = new MsSqlFacade<CategoriasClientes, CategoriasClientesMapper>())
         {
             // we now select all the promotions that are active but we make it into a linear research
             // thus is not woow efficient is enought for it's end. 
             return facade.Create(broker);
         }
     }
     catch
     {
         /// in case that fails, we give an empty list
         return -1;
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="Promocion"></param>
 /// <param name="Cliente"></param>
 /// <returns></returns>
 public static string ComprarPromocion(int Promocion, int Cliente)
 {
     try
     {
         using (MsSqlFacade<ComprasPromociones, ComprasPromocionesMapper> facade = new MsSqlFacade<ComprasPromociones, ComprasPromocionesMapper>())
         {
             /// this is the guid
             string guid = Guid.NewGuid().ToString();
             //// we select all the promotion that are active first
             facade.Create(new ComprasPromociones() { Cliente = Cliente, Promocion = Promocion, Estado = 0, FechaCambioEstado = "", FechaCompra = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") , Guid = guid});
             /// return the guid
             return guid;
         }
     }
     catch
     {
         /// in case that fails, we give an empty list
         return null;
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="cliente"></param>
        /// <returns></returns>
        public static int CreateCliente(Clientes cliente)
        {
            try
            {
                using (MsSqlFacade<Clientes, ClientesMapper> facade = new MsSqlFacade<Clientes, ClientesMapper>())
                {
                    
                    int id =  facade.Create(cliente);

                    using (MsSqlFacade<PerfilClientes, PerfilClientesMapper> facade1 = new MsSqlFacade<PerfilClientes, PerfilClientesMapper>())
                    {
                        facade1.Create(new PerfilClientes() { AprendizajeCompras = 0, ToleranciaDistancia = 0, TipoAlerta = 0, Cliente = id });
                    }

                    return id;
                }
            }
            catch
            {
                /// in case that fails, we give an empty list
                return -1;
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="axis"></param>
 /// <param name="cliente"></param>
 /// <returns></returns>
 public static int AcknowledgeRutas(string axis, string speed, int cliente)
 {
     try
     {
         using (MsSqlFacade<Rutas, RutasMapper> facade = new MsSqlFacade<Rutas, RutasMapper>())
         {
             //// we use the Collection to build the broker entity on an abstract phase to manage it as a all
             return facade.Create(new Rutas() { Axis = axis, Speed = speed, Cliente = cliente, Fecha = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
         }
     }
     catch
     {
         return -1;
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="axis"></param>
 /// <param name="cliente"></param>
 public static int AcknowledgePosition(string axis, int mercante)
 {
     try
     {
         using (MsSqlFacade<Positions, PositionsMapper> facade = new MsSqlFacade<Positions, PositionsMapper>())
         {
             //// we use the Collection to build the broker entity on an abstract phase to manage it as a all
             return facade.Create(new Positions() { Axis = axis, Mercante = mercante });
         }
     }
     catch
     {
         return -1;
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="broker"></param>
 /// <returns></returns>
 public static int CreateClientesMercantes(data.entities.ClientesMercantes broker)
 {
     try
     {
         using (MsSqlFacade<ClientesMercantes, ClientesMercantesMapper> facade = new MsSqlFacade<ClientesMercantes, ClientesMercantesMapper>())
         {
             //// we select all the promotion that are active first
             return facade.Create(broker);
         }
     }
     catch
     {
         /// in case that fails, we give an empty list
         return -1;
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="broker"></param>
 /// <returns></returns>
 public static int CreateItemProductos(data.entities.ItemProductos broker)
 {
     try
     {
         using (MsSqlFacade<ItemProductos, ItemProductosMapper> facade = new MsSqlFacade<ItemProductos, ItemProductosMapper>())
         {
             //// we select all the promotion that are active first
             return facade.Create(broker);
         }
     }
     catch
     {
         /// in case that fails, we give an empty list
         return -1;
     }
 }