/// <summary> /// Obtener Datos Cliente /// </summary> /// <param name="IdCliente"></param> /// <returns></returns> public List <Cliente> ObtenerDatosCliente(int IdCliente) { List <Cliente> listaCarrito = new List <Cliente>(); try { using (CarritoDataContext CarritoBD = new CarritoDataContext()) { List <sp_ObtieneDatosClientePorClienteResult> list = CarritoBD.sp_ObtieneDatosClientePorCliente(IdCliente).ToList(); foreach (var item in list) { Cliente objCarrito = new Cliente(); objCarrito.IdCliente = item.IdCliente; objCarrito.Nombre = item.Nombre; objCarrito.Email = item.Email; objCarrito.Apellido = item.Apellido; objCarrito.Telefono = item.Telefono; objCarrito.Direccion = item.Direccion; objCarrito.Contrasena = item.Contrasena; listaCarrito.Add(objCarrito); } return(listaCarrito); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosCliente", ex.Message, ex.StackTrace); return(listaCarrito); } }
/// <summary> /// Obtiene los metodos de pago /// </summary> /// <returns></returns> public List <MetodoPago> ObtieneMetodosPago() { List <MetodoPago> listaMetodosPago = new List <MetodoPago>(); try { using (CarritoDataContext MetodoPagoDB = new CarritoDataContext()) { //List<sp_ObtieneMetodosPagoResult> list = MetodoPagoDB.sp_ObtieneMetodosPago().ToList(); //foreach (var item in list) //{ // MetodoPago objCarrito = new MetodoPago(); // objCarrito.IdMetodoPago = item.IdMetodoPago; // objCarrito.NombreMetodoPAgo = item.NombreMetodoPAgo; // listaMetodosPago.Add(objCarrito); //} return(listaMetodosPago); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosFactura", ex.Message, ex.StackTrace); return(listaMetodosPago); } }
/// <summary> /// Login Cliente /// </summary> /// <param name="Email"></param> /// <param name="Contrasena"></param> /// <returns></returns> public Cliente Login(string Email, string Contrasena) { Cliente cliente = new Cliente(); try { using (CarritoDataContext CarritoBD = new CarritoDataContext()) { sp_LoginClienteResult result = CarritoBD.sp_LoginCliente(Email, Contrasena).FirstOrDefault(); cliente.IdCliente = result.IdCliente; cliente.Nombre = result.Nombre; cliente.Apellido = result.Apellido; cliente.Email = result.Email; cliente.Telefono = result.Telefono; return(cliente); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosCliente", ex.Message, ex.StackTrace); return(cliente); } }
/// <summary> /// Obtiene la todos los productos por categoria /// </summary> /// <param name="IdCategoria"></param> /// <returns></returns> public List <Producto> ObtenerProductosXCategoria(int IdCategoria) { List <Producto> listaProductos = new List <Producto>(); try { using (CarritoDataContext Carrito = new CarritoDataContext()) { List <sp_ObtieneProductosPorCategoriaResult> list = Carrito.sp_ObtieneProductosPorCategoria(IdCategoria).ToList(); foreach (var item in list) { Producto objProducto = new Producto(); objProducto.IdProducto = item.IdProducto; objProducto.NombreProducto = item.NombreProducto; objProducto.PrecioProducto = item.PrecioProducto; objProducto.DescripcionProducto = item.DescripcionProducto; objProducto.IdCategoria = item.IdCategoria; objProducto.ImagenProducto = item.ImagenProducto; listaProductos.Add(objProducto); } return(listaProductos); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "AccesoDatosProducto", ex.Message, ex.StackTrace); return(listaProductos); } }
public int CrearFactura(int IdCliente, decimal total) { try { using (CarritoDataContext FacturaDB = new CarritoDataContext()) { DateTime fechaFactura = DateTime.Now; sp_CrearFacturaResult factura = FacturaDB.sp_CrearFactura(IdCliente, fechaFactura, total).FirstOrDefault(); return((int)factura.ID); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosFactura", ex.Message, ex.StackTrace); return(0); } }
public bool VaciarCarrito(int IdCliente) { try { using (CarritoDataContext FacturaDB = new CarritoDataContext()) { FacturaDB.sp_VaciarCarrito(IdCliente); return(true); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosFactura", ex.Message, ex.StackTrace); return(false); } }
public List <sp_ObtieneItemsFacturaIdResult> ObtieneItemsFactura(int IdFactura) { List <sp_ObtieneItemsFacturaIdResult> listaItems = null; try { using (CarritoDataContext FacturaDB = new CarritoDataContext()) { listaItems = FacturaDB.sp_ObtieneItemsFacturaId(IdFactura).ToList(); return(listaItems); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosFactura", ex.Message, ex.StackTrace); return(listaItems); } }
public sp_ObtieneFacturaIdResult ObtieneFactura(int IdFactura) { sp_ObtieneFacturaIdResult factura = null; try { using (CarritoDataContext FacturaDB = new CarritoDataContext()) { factura = FacturaDB.sp_ObtieneFacturaId(IdFactura).FirstOrDefault(); return(factura); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosFactura", ex.Message, ex.StackTrace); return(factura); } }
/// <summary> /// Inserta los datos del cliente /// </summary> /// <param name="objCliente"></param> /// <returns></returns> public int InsertarDatosCliente(Cliente objCliente) { int resultado = 0; try { using (CarritoDataContext CarritoBD = new CarritoDataContext()) { CarritoBD.sp_InsertarDatosCliente(objCliente.Nombre, objCliente.Apellido, objCliente.Email, objCliente.Telefono, objCliente.Direccion, objCliente.Contrasena); resultado = 1; return(resultado); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosCliente", ex.Message, ex.StackTrace); return(resultado); } }
/// <summary> /// Elimina el carrito por cliente /// </summary> /// <param name="IDCarrito"></param> /// <returns></returns> public int EliminarCarritoPorCliente(int IdCarrito) { int resultado = 0; try { using (CarritoDataContext CarritoBD = new CarritoDataContext()) { CarritoBD.sp_EliminarCarritoPorCliente(IdCarrito); resultado = (int)EnumResultadoOperacion.Exito; return(resultado); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosCarrito", ex.Message, ex.StackTrace); return(resultado = (int)EnumResultadoOperacion.Error); } }
/// <summary> /// Obtiene el carrito por cliente /// </summary> /// <param name="IdUsuario"></param> /// <returns></returns> public List <Carrito> ObtenerCarritoPorCliente(int IdUsuario) { List <Carrito> listaCarrito = new List <Carrito>(); try { using (CarritoDataContext CarritoBD = new CarritoDataContext()) { List <sp_ObtieneCarritoPorClienteResult> list = CarritoBD.sp_ObtieneCarritoPorCliente(IdUsuario).ToList(); foreach (var item in list) { Carrito objCarrito = new Carrito(); objCarrito.IdCarrito = item.IdCarrito; objCarrito.IdUsuario = item.IdCliente; objCarrito.NombreCliente = item.Nombre; objCarrito.ApellidoCliente = item.Apellido; objCarrito.IdProducto = item.IdProducto; objCarrito.NombreProducto = item.NombreProducto; objCarrito.ImagenProducto = item.ImagenProducto; objCarrito.DescripcionProducto = item.DescripcionProducto; objCarrito.IdCategoria = item.IdCategoria; objCarrito.Cantidad = item.Cantidad; objCarrito.CantidadDisponible = item.CantidadDisponibles; objCarrito.PrecioProducto = item.PrecioProducto; listaCarrito.Add(objCarrito); } return(listaCarrito); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosCarrito", ex.Message, ex.StackTrace); return(listaCarrito); } }
public bool InsertarItemsFactura(List <Carrito> Carrito, int IdFactura) { try { using (CarritoDataContext FacturaDB = new CarritoDataContext()) { foreach (var item in Carrito) { decimal subTotal = 0; subTotal = (decimal)(subTotal + (item.PrecioProducto * item.Cantidad)); FacturaDB.sp_AgregarItemsFactura(item.IdProducto, IdFactura, item.Cantidad, subTotal); } return(true); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "DatosFactura", ex.Message, ex.StackTrace); return(false); } }
/// <summary> /// Obtiene la cantidad de productos disponibles por Id /// </summary> /// <param name="IdProducto"></param> /// <returns></returns> public int ObtieneCantidadProductos(int IdProducto) { int CantidadDisponible = 0; try { List <Producto> ProductoDisponible = new List <Producto>(); using (CarritoDataContext Carrito = new CarritoDataContext()) { List <sp_ObtieneCantidadProductosResult> list = Carrito.sp_ObtieneCantidadProductos(IdProducto).ToList(); CantidadDisponible = list[0].CantidadDisponibles; return(CantidadDisponible); } } catch (Exception ex) { GuardaErrores ErroresLog = new GuardaErrores(); string NombreMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; ErroresLog.InsertarErrores(NombreMetodo, "AccesoDatosProducto", ex.Message, ex.StackTrace); return(CantidadDisponible); } }