DetalleVenta { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Pages/Error.cshtml:
--------------------------------------------------------------------------------
1 | @page
2 | @model ErrorModel
3 | @{
4 | ViewData["Title"] = "Error";
5 | }
6 |
7 | Error.
8 | An error occurred while processing your request.
9 |
10 | @if (Model.ShowRequestId)
11 | {
12 |
13 | Request ID: @Model.RequestId
14 |
15 | }
16 |
17 | Development Mode
18 |
19 | Swapping to the Development environment displays detailed information about the error that occurred.
20 |
21 |
22 | The Development environment shouldn't be enabled for deployed applications.
23 | It can result in displaying sensitive information from exceptions to end users.
24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
25 | and restarting the app.
26 |
27 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Pages/Error.cshtml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.RazorPages;
3 | using System.Diagnostics;
4 |
5 | namespace SistemaVentaAngular.Pages
6 | {
7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8 | public class ErrorModel : PageModel
9 | {
10 | private readonly ILogger _logger;
11 |
12 | public ErrorModel(ILogger logger)
13 | {
14 | _logger = logger;
15 | }
16 |
17 | public string? RequestId { get; set; }
18 |
19 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
20 |
21 | public void OnGet()
22 | {
23 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/SistemaVentaAngular/Pages/_ViewImports.cshtml:
--------------------------------------------------------------------------------
1 | @using SistemaVentaAngular
2 | @namespace SistemaVentaAngular.Pages
3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using SistemaVentaAngular.Models;
3 | using SistemaVentaAngular.Repository.Contratos;
4 | using SistemaVentaAngular.Repository.Implementacion;
5 | using SistemaVentaAngular.Utilidades;
6 |
7 | var builder = WebApplication.CreateBuilder(args);
8 |
9 | // Add services to the container.
10 |
11 | builder.Services.AddControllersWithViews();
12 |
13 |
14 | builder.Services.AddDbContext(options =>
15 | {
16 | options.UseSqlServer(builder.Configuration.GetConnectionString("sqlConection"));
17 | });
18 | builder.Services.AddAutoMapper(typeof(AutoMapperProfile));
19 |
20 | builder.Services.AddScoped();
21 | builder.Services.AddScoped();
22 | builder.Services.AddScoped();
23 | builder.Services.AddScoped();
24 | builder.Services.AddScoped();
25 | builder.Services.AddScoped();
26 |
27 | var app = builder.Build();
28 |
29 | // Configure the HTTP request pipeline.
30 | if (!app.Environment.IsDevelopment())
31 | {
32 | }
33 |
34 | app.UseStaticFiles();
35 | app.UseRouting();
36 |
37 |
38 | app.MapControllerRoute(
39 | name: "default",
40 | pattern: "{controller}/{action=Index}/{id?}");
41 |
42 | app.MapFallbackToFile("index.html"); ;
43 |
44 | app.Run();
45 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:64159",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "SistemaVentaAngular": {
12 | "commandName": "Project",
13 | "launchBrowser": true,
14 | "applicationUrl": "http://localhost:5293",
15 | "environmentVariables": {
16 | "ASPNETCORE_ENVIRONMENT": "Development",
17 | "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
18 | }
19 | },
20 | "IIS Express": {
21 | "commandName": "IISExpress",
22 | "launchBrowser": true,
23 | "environmentVariables": {
24 | "ASPNETCORE_ENVIRONMENT": "Development",
25 | "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Contratos/ICategoriaRepositorio.cs:
--------------------------------------------------------------------------------
1 | using SistemaVentaAngular.Models;
2 |
3 | namespace SistemaVentaAngular.Repository.Contratos
4 | {
5 | public interface ICategoriaRepositorio
6 | {
7 | Task> Lista();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Contratos/IDashBoardRepositorio.cs:
--------------------------------------------------------------------------------
1 | namespace SistemaVentaAngular.Repository.Contratos
2 | {
3 | public interface IDashBoardRepositorio
4 | {
5 | Task TotalVentasUltimaSemana();
6 | Task TotalIngresosUltimaSemana();
7 | Task TotalProductos();
8 | Task> VentasUltimaSemana();
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Contratos/IProductoRepositorio.cs:
--------------------------------------------------------------------------------
1 | using SistemaVentaAngular.Models;
2 | using System.Linq.Expressions;
3 |
4 | namespace SistemaVentaAngular.Repository.Contratos
5 | {
6 | public interface IProductoRepositorio
7 | {
8 | Task Obtener(Expression> filtro = null);
9 | Task Crear(Producto entidad);
10 | Task Editar(Producto entidad);
11 | Task Eliminar(Producto entidad);
12 | Task> Consultar(Expression> filtro = null);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Contratos/IRolRepositorio.cs:
--------------------------------------------------------------------------------
1 | using SistemaVentaAngular.Models;
2 |
3 | namespace SistemaVentaAngular.Repository.Contratos
4 | {
5 | public interface IRolRepositorio
6 | {
7 | Task> Lista();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Contratos/IUsuarioRepositorio.cs:
--------------------------------------------------------------------------------
1 | using SistemaVentaAngular.Models;
2 | using System.Linq.Expressions;
3 |
4 | namespace SistemaVentaAngular.Repository.Contratos
5 | {
6 | public interface IUsuarioRepositorio
7 | {
8 | Task> Lista();
9 | Task Obtener(Expression> filtro = null);
10 | Task Crear(Usuario entidad);
11 | Task Editar(Usuario entidad);
12 | Task Eliminar(Usuario entidad);
13 | Task> Consultar(Expression> filtro = null);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Contratos/IVentaRepositorio.cs:
--------------------------------------------------------------------------------
1 | using SistemaVentaAngular.Models;
2 |
3 | namespace SistemaVentaAngular.Repository.Contratos
4 | {
5 | public interface IVentaRepositorio
6 | {
7 | Task Registrar(Venta entidad);
8 | Task> Historial(string buscarPor,string numeroVenta, string fechaInicio, string fechaFin);
9 | Task> Reporte(DateTime FechaInicio, DateTime FechaFin);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Implementacion/CategoriaRepositorio.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using SistemaVentaAngular.Models;
3 | using SistemaVentaAngular.Repository.Contratos;
4 |
5 | namespace SistemaVentaAngular.Repository.Implementacion
6 | {
7 | public class CategoriaRepositorio : ICategoriaRepositorio
8 | {
9 | private readonly DBVentaAngularContext _dbContext;
10 |
11 | public CategoriaRepositorio(DBVentaAngularContext dbContext)
12 | {
13 | _dbContext = dbContext;
14 | }
15 | public async Task> Lista()
16 | {
17 | try
18 | {
19 | return await _dbContext.Categoria.ToListAsync();
20 | }
21 | catch
22 | {
23 | throw;
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Implementacion/DashBoardRepositorio.cs:
--------------------------------------------------------------------------------
1 | using SistemaVentaAngular.Models;
2 | using SistemaVentaAngular.Repository.Contratos;
3 | using System.Globalization;
4 |
5 | namespace SistemaVentaAngular.Repository.Implementacion
6 | {
7 | public class DashBoardRepositorio : IDashBoardRepositorio
8 | {
9 | private readonly DBVentaAngularContext _dbcontext;
10 | public DashBoardRepositorio(DBVentaAngularContext context)
11 | {
12 | _dbcontext = context;
13 | }
14 |
15 | public async Task TotalVentasUltimaSemana()
16 | {
17 | int total = 0;
18 | try
19 | {
20 | IQueryable _ventaQuery = _dbcontext.Venta.AsQueryable();
21 |
22 | if (_ventaQuery.Count() > 0) {
23 | DateTime? ultimaFecha = _dbcontext.Venta.OrderByDescending(v => v.FechaRegistro).Select(v => v.FechaRegistro).First();
24 |
25 | ultimaFecha = ultimaFecha.Value.AddDays(-7);
26 |
27 | IQueryable query = _dbcontext.Venta.Where(v => v.FechaRegistro.Value.Date >= ultimaFecha.Value.Date);
28 | total = query.Count();
29 | }
30 |
31 | return total;
32 | }
33 | catch
34 | {
35 | throw;
36 | }
37 | }
38 | public async Task TotalIngresosUltimaSemana()
39 | {
40 | decimal resultado = 0;
41 | try
42 | {
43 | IQueryable _ventaQuery = _dbcontext.Venta.AsQueryable();
44 |
45 | if (_ventaQuery.Count() > 0)
46 | {
47 | DateTime? ultimaFecha = _dbcontext.Venta.OrderByDescending(v => v.FechaRegistro).Select(v => v.FechaRegistro).First();
48 | ultimaFecha = ultimaFecha.Value.AddDays(-7);
49 | IQueryable query = _dbcontext.Venta.Where(v => v.FechaRegistro.Value.Date >= ultimaFecha.Value.Date);
50 |
51 | resultado = query
52 | .Select(v => v.Total)
53 | .Sum(v => v.Value);
54 | }
55 |
56 |
57 | return Convert.ToString(resultado, new CultureInfo("es-PE"));
58 | }
59 | catch
60 | {
61 | throw;
62 | }
63 |
64 |
65 | }
66 | public async Task TotalProductos()
67 | {
68 | try
69 | {
70 | IQueryable query = _dbcontext.Productos;
71 | int total = query.Count();
72 | return total;
73 | }
74 | catch
75 | {
76 | throw;
77 | }
78 | }
79 |
80 | public async Task> VentasUltimaSemana()
81 | {
82 | Dictionary resultado = new Dictionary();
83 | try
84 | {
85 | IQueryable _ventaQuery = _dbcontext.Venta.AsQueryable();
86 | if (_ventaQuery.Count() > 0) {
87 | DateTime? ultimaFecha = _dbcontext.Venta.OrderByDescending(v => v.FechaRegistro).Select(v => v.FechaRegistro).First();
88 | ultimaFecha = ultimaFecha.Value.AddDays(-7);
89 |
90 | IQueryable query = _dbcontext.Venta.Where(v => v.FechaRegistro.Value.Date >= ultimaFecha.Value.Date);
91 |
92 | resultado = query
93 | .GroupBy(v => v.FechaRegistro.Value.Date).OrderBy(g => g.Key)
94 | .Select(dv => new { fecha = dv.Key.ToString("dd/MM/yyyy"), total = dv.Count() })
95 | .ToDictionary(keySelector: r => r.fecha, elementSelector: r => r.total);
96 | }
97 |
98 |
99 | return resultado;
100 |
101 | }
102 | catch
103 | {
104 | throw;
105 | }
106 |
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Implementacion/ProductoRepositorio.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using SistemaVentaAngular.Models;
3 | using SistemaVentaAngular.Repository.Contratos;
4 | using System.Linq.Expressions;
5 |
6 | namespace SistemaVentaAngular.Repository.Implementacion
7 | {
8 | public class ProductoRepositorio : IProductoRepositorio
9 | {
10 | private readonly DBVentaAngularContext _dbContext;
11 |
12 | public ProductoRepositorio(DBVentaAngularContext dbContext)
13 | {
14 | _dbContext = dbContext;
15 | }
16 | public async Task> Consultar(Expression> filtro = null)
17 | {
18 | IQueryable queryEntidad = filtro == null ? _dbContext.Productos : _dbContext.Productos.Where(filtro);
19 | return queryEntidad;
20 | }
21 |
22 | public async Task Crear(Producto entidad)
23 | {
24 | try
25 | {
26 | _dbContext.Set().Add(entidad);
27 | await _dbContext.SaveChangesAsync();
28 | return entidad;
29 | }
30 | catch
31 | {
32 | throw;
33 | }
34 | }
35 |
36 | public async Task Editar(Producto entidad)
37 | {
38 | try
39 | {
40 | _dbContext.Update(entidad);
41 | await _dbContext.SaveChangesAsync();
42 | return true;
43 | }
44 | catch
45 | {
46 | throw;
47 | }
48 | }
49 |
50 | public async Task Eliminar(Producto entidad)
51 | {
52 | try
53 | {
54 | _dbContext.Remove(entidad);
55 | await _dbContext.SaveChangesAsync();
56 | return true;
57 | }
58 | catch
59 | {
60 | throw;
61 | }
62 | }
63 |
64 | public async Task Obtener(Expression> filtro = null)
65 | {
66 | try
67 | {
68 | return await _dbContext.Productos.Where(filtro).FirstOrDefaultAsync();
69 | }
70 | catch
71 | {
72 | throw;
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Implementacion/RolRepositorio.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using SistemaVentaAngular.Models;
3 | using SistemaVentaAngular.Repository.Contratos;
4 | using System.Linq.Expressions;
5 |
6 | namespace SistemaVentaAngular.Repository.Implementacion
7 | {
8 | public class RolRepositorio : IRolRepositorio
9 | {
10 | private readonly DBVentaAngularContext _dbContext;
11 |
12 | public RolRepositorio(DBVentaAngularContext dbContext)
13 | {
14 | _dbContext = dbContext;
15 | }
16 | public async Task> Lista()
17 | {
18 | try
19 | {
20 | return await _dbContext.Rols.ToListAsync();
21 | }
22 | catch
23 | {
24 | throw;
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Implementacion/UsuarioRepositorio.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using SistemaVentaAngular.Models;
3 | using SistemaVentaAngular.Repository.Contratos;
4 | using System.Linq.Expressions;
5 |
6 | namespace SistemaVentaAngular.Repository.Implementacion
7 | {
8 | public class UsuarioRepositorio : IUsuarioRepositorio
9 | {
10 | private readonly DBVentaAngularContext _dbContext;
11 |
12 | public UsuarioRepositorio(DBVentaAngularContext dbContext)
13 | {
14 | _dbContext = dbContext;
15 | }
16 |
17 | public async Task> Consultar(Expression> filtro = null)
18 | {
19 | IQueryable queryEntidad = filtro == null ? _dbContext.Usuarios : _dbContext.Usuarios.Where(filtro);
20 | return queryEntidad;
21 | }
22 |
23 | public async Task Crear(Usuario entidad)
24 | {
25 | try
26 | {
27 | _dbContext.Set().Add(entidad);
28 | await _dbContext.SaveChangesAsync();
29 | return entidad;
30 | }
31 | catch
32 | {
33 | throw;
34 | }
35 | }
36 |
37 | public async Task Editar(Usuario entidad)
38 | {
39 | try
40 | {
41 | _dbContext.Update(entidad);
42 | await _dbContext.SaveChangesAsync();
43 | return true;
44 | }
45 | catch
46 | {
47 | throw;
48 | }
49 | }
50 |
51 | public async Task Eliminar(Usuario entidad)
52 | {
53 | try
54 | {
55 | _dbContext.Remove(entidad);
56 | await _dbContext.SaveChangesAsync();
57 | return true;
58 | }
59 | catch
60 | {
61 | throw;
62 | }
63 | }
64 |
65 | public async Task> Lista()
66 | {
67 | try
68 | {
69 | return await _dbContext.Usuarios.ToListAsync();
70 | }
71 | catch
72 | {
73 | throw;
74 | }
75 | }
76 |
77 | public async Task Obtener(Expression> filtro = null)
78 | {
79 | try
80 | {
81 | return await _dbContext.Usuarios.Where(filtro).FirstOrDefaultAsync();
82 | }
83 | catch
84 | {
85 | throw;
86 | }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Repository/Implementacion/VentaRepositorio.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using SistemaVentaAngular.Models;
3 | using SistemaVentaAngular.Repository.Contratos;
4 | using System.Globalization;
5 |
6 | namespace SistemaVentaAngular.Repository.Implementacion
7 | {
8 | public class VentaRepositorio : IVentaRepositorio
9 | {
10 | private readonly DBVentaAngularContext _dbcontext;
11 | public VentaRepositorio(DBVentaAngularContext context)
12 | {
13 | _dbcontext = context;
14 | }
15 |
16 | public async Task Registrar(Venta entidad)
17 | {
18 | Venta VentaGenerada = new Venta();
19 |
20 | //usaremos transacion, ya que si ocurre un error en algun insert a una tabla, debe reestablecer todo a cero, como si no hubo o no existió ningun insert
21 | using (var transaction = _dbcontext.Database.BeginTransaction())
22 | {
23 | int CantidadDigitos = 4;
24 | try
25 | {
26 | foreach (DetalleVenta dv in entidad.DetalleVenta)
27 | {
28 | Producto producto_encontrado = _dbcontext.Productos.Where(p => p.IdProducto == dv.IdProducto).First();
29 |
30 | producto_encontrado.Stock = producto_encontrado.Stock - dv.Cantidad;
31 | _dbcontext.Productos.Update(producto_encontrado);
32 | }
33 | await _dbcontext.SaveChangesAsync();
34 |
35 |
36 | NumeroDocumento correlativo = _dbcontext.NumeroDocumentos.First();
37 |
38 | correlativo.UltimoNumero = correlativo.UltimoNumero + 1;
39 | correlativo.FechaRegistro = DateTime.Now;
40 |
41 | _dbcontext.NumeroDocumentos.Update(correlativo);
42 | await _dbcontext.SaveChangesAsync();
43 |
44 |
45 | string ceros = string.Concat(Enumerable.Repeat("0", CantidadDigitos));
46 | string numeroVenta = ceros + correlativo.UltimoNumero.ToString();
47 | numeroVenta = numeroVenta.Substring(numeroVenta.Length - CantidadDigitos, CantidadDigitos);
48 |
49 | entidad.NumeroDocumento = numeroVenta;
50 |
51 | await _dbcontext.Venta.AddAsync(entidad);
52 | await _dbcontext.SaveChangesAsync();
53 |
54 | VentaGenerada = entidad;
55 |
56 | transaction.Commit();
57 | }
58 | catch (Exception ex)
59 | {
60 | transaction.Rollback();
61 | throw;
62 | }
63 | }
64 |
65 | return VentaGenerada;
66 | }
67 |
68 | public async Task> Historial(string buscarPor,string numeroVenta, string fechaInicio, string fechaFin)
69 | {
70 | IQueryable query = _dbcontext.Venta;
71 |
72 | if (buscarPor == "fecha")
73 | {
74 |
75 | DateTime fech_Inicio = DateTime.ParseExact(fechaInicio, "dd/MM/yyyy", new CultureInfo("es-PE"));
76 | DateTime fech_Fin = DateTime.ParseExact(fechaFin, "dd/MM/yyyy", new CultureInfo("es-PE"));
77 |
78 | return query.Where(v =>
79 | v.FechaRegistro.Value.Date >= fech_Inicio.Date &&
80 | v.FechaRegistro.Value.Date <= fech_Fin.Date
81 | )
82 | .Include(dv => dv.DetalleVenta)
83 | .ThenInclude(p => p.IdProductoNavigation)
84 | .ToList();
85 |
86 | }
87 | else {
88 | return query.Where(v => v.NumeroDocumento == numeroVenta)
89 | .Include(dv => dv.DetalleVenta)
90 | .ThenInclude(p => p.IdProductoNavigation)
91 | .ToList();
92 | }
93 |
94 |
95 | }
96 |
97 | public async Task> Reporte(DateTime FechaInicio, DateTime FechaFin)
98 | {
99 | List listaResumen = await _dbcontext.DetalleVenta
100 | .Include(p => p.IdProductoNavigation)
101 | .Include(v => v.IdVentaNavigation)
102 | .Where(dv => dv.IdVentaNavigation.FechaRegistro.Value.Date >= FechaInicio.Date && dv.IdVentaNavigation.FechaRegistro.Value.Date <= FechaFin.Date)
103 | .ToListAsync();
104 |
105 | return listaResumen;
106 | }
107 |
108 |
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/SistemaVentaAngular.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | enable
6 | false
7 | ClientApp\
8 | http://localhost:44496
9 | npm start
10 | enable
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | all
20 | runtime; build; native; contentfiles; analyzers; buildtransitive
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | wwwroot\%(RecursiveDir)%(FileName)%(Extension)
57 | PreserveNewest
58 | true
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/SistemaVentaAngular/Utilidades/AutoMapperProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using SistemaVentaAngular.DTOs;
3 | using SistemaVentaAngular.Models;
4 | using System.Globalization;
5 |
6 | namespace SistemaVentaAngular.Utilidades
7 | {
8 | public class AutoMapperProfile : Profile
9 | {
10 | public AutoMapperProfile()
11 | {
12 | #region Rol
13 | CreateMap().ReverseMap();
14 | #endregion Rol
15 |
16 | #region Usuario
17 | CreateMap()
18 | .ForMember(destino =>
19 | destino.rolDescripcion,
20 | opt => opt.MapFrom(origen => origen.IdRolNavigation.Descripcion)
21 | );
22 |
23 | CreateMap()
24 | .ForMember(destino =>
25 | destino.IdRolNavigation,
26 | opt => opt.Ignore()
27 | );
28 | #endregion Usuario
29 |
30 | #region Categoria
31 | CreateMap().ReverseMap();
32 | #endregion Categoria
33 |
34 |
35 | #region Producto
36 | CreateMap()
37 | .ForMember(destino =>
38 | destino.DescripcionCategoria,
39 | opt => opt.MapFrom(origen => origen.IdCategoriaNavigation.Descripcion)
40 | )
41 | .ForMember(destino =>
42 | destino.Precio,
43 | opt => opt.MapFrom(origen => Convert.ToString(origen.Precio.Value, new CultureInfo("es-PE")))
44 | );
45 |
46 | CreateMap()
47 | .ForMember(destino =>
48 | destino.IdCategoriaNavigation,
49 | opt => opt.Ignore()
50 | )
51 | .ForMember(destiono =>
52 | destiono.Precio,
53 | opt => opt.MapFrom(origen => Convert.ToDecimal(origen.Precio, new CultureInfo("es-PE")))
54 | );
55 | #endregion Producto
56 |
57 |
58 | #region Venta
59 | CreateMap()
60 | .ForMember(destino =>
61 | destino.TotalTexto,
62 | opt => opt.MapFrom(origen => Convert.ToString(origen.Total.Value, new CultureInfo("es-PE")))
63 | ).ForMember(destino =>
64 | destino.FechaRegistro,
65 | opt => opt.MapFrom(origen => origen.FechaRegistro.Value.ToString("dd/MM/yyyy"))
66 | );
67 |
68 | CreateMap()
69 | .ForMember(destino =>
70 | destino.Total,
71 | opt => opt.MapFrom(origen => Convert.ToDecimal(origen.TotalTexto, new CultureInfo("es-PE")))
72 | );
73 |
74 | #endregion Venta
75 |
76 |
77 | #region DetalleVenta
78 | CreateMap()
79 | .ForMember(destino =>
80 | destino.DescripcionProducto,
81 | opt => opt.MapFrom(origen => origen.IdProductoNavigation.Nombre)
82 | )
83 | .ForMember(destino =>
84 | destino.PrecioTexto,
85 | opt => opt.MapFrom(origen => Convert.ToString(origen.Precio.Value, new CultureInfo("es-PE")))
86 | )
87 | .ForMember(destino =>
88 | destino.TotalTexto,
89 | opt => opt.MapFrom(origen => Convert.ToString(origen.Total.Value, new CultureInfo("es-PE")))
90 | );
91 |
92 | CreateMap