Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4478dc7
Add layers and brands
JorgeHB69 Oct 28, 2024
bb0e839
Merge remote-tracking branch 'origin/feat/coronel/combos_crud_impleme…
JorgeHB69 Oct 28, 2024
2a996c7
Home screen view finished
JorgeHB69 Oct 28, 2024
f78b2de
Prepare interaction with api
JorgeHB69 Oct 28, 2024
859293c
Merge branch 'develop' of https://github.com/JeferssonCL/WebProgrammi…
JorgeHB69 Oct 28, 2024
fba4c85
Merge branch 'develop' of https://github.com/JeferssonCL/WebProgrammi…
JorgeHB69 Oct 28, 2024
fa27e53
Merge branch 'develop' of https://github.com/JeferssonCL/WebProgrammi…
JorgeHB69 Oct 29, 2024
4da0b82
request combos fron database
JorgeHB69 Oct 29, 2024
1e71660
connect with database
JorgeHB69 Oct 29, 2024
16c0078
Show default image until database returns the corrects
JorgeHB69 Oct 29, 2024
d3e02f5
feat : adding user service
daniel-espinoza-79 Oct 29, 2024
1cb6db9
Merge remote-tracking branch 'origin/fix/gandarillas/fix_data_persist…
JorgeHB69 Oct 29, 2024
32bcab8
Merge branch 'fix/gandarillas/fix_data_persistence' of https://github…
JorgeHB69 Oct 29, 2024
c84c0b0
Load images from DB
JorgeHB69 Oct 29, 2024
2710a19
Add combo details page
JorgeHB69 Oct 29, 2024
8d77a70
Separation of brands
JorgeHB69 Oct 29, 2024
36c7d2c
Merge branch 'develop' of https://github.com/JeferssonCL/WebProgrammi…
JorgeHB69 Oct 29, 2024
59aba44
Add combo to cart
JorgeHB69 Oct 29, 2024
95d5c04
adding product
daniel-espinoza-79 Oct 29, 2024
5dc84aa
Send to cart
JorgeHB69 Oct 29, 2024
40cb6e3
Merge branch 'feat/espinoza/user-service-impl' of https://github.com/…
JorgeHB69 Oct 29, 2024
049a859
correct logo on header
JorgeHB69 Oct 29, 2024
7e9eab2
add authorization
daniel-espinoza-79 Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# MacOS
.DS_Store

.env
# Windows
Thumbs.db
ehthumbs.db
Expand Down
58 changes: 0 additions & 58 deletions Backend/Backend.Api/Controllers/AuthController.cs

This file was deleted.

4 changes: 4 additions & 0 deletions Backend/Backend.Api/Controllers/ComboController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Backend.Application.Handlers.Combos.Requests.Commands;
using Backend.Application.Handlers.Combos.Requests.Queries;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Backend.Api.Controllers;
Expand All @@ -12,6 +13,7 @@ namespace Backend.Api.Controllers;
public class ComboController(IMediator mediator) : ControllerBase
{
[HttpPost]
[Authorize]
public async Task<ActionResult<Dictionary<string, bool>>> Create([FromBody] CreateComboDto request)
{
var result = await mediator.Send(new CreateComboCommand(request));
Expand Down Expand Up @@ -45,6 +47,7 @@ public async Task<ActionResult<List<ComboWithDiscountDto>>> GetAllProductWithDis
}

[HttpPut("{id}")]
[Authorize]
public async Task<IActionResult> Update(Guid id, [FromBody] UpdateComboDto request)
{
if (id != request.Id) return BadRequest();
Expand All @@ -54,6 +57,7 @@ public async Task<IActionResult> Update(Guid id, [FromBody] UpdateComboDto reque
}

[HttpDelete("{id}")]
[Authorize]
public async Task<IActionResult> Delete(Guid id)
{
var result = await mediator.Send(new DeleteComboCommand(id));
Expand Down
6 changes: 1 addition & 5 deletions Backend/Backend.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
using Microsoft.EntityFrameworkCore;
using Backend.Application;
using Backend.Infrastructure.Context;
using Backend.Infrastructure.Repositories.Interfaces;
using Backend.Infrastructure.Repositories.Concretes;
using Backend.Application.Services.Auth.Interfaces;
using Backend.Application.Services.Auth.Concretes;

var builder = WebApplication.CreateBuilder(args);

Env.Load("../.env");
Env.Load("../../.env");

builder.Services.AddCors(options =>
{
Expand Down
10 changes: 2 additions & 8 deletions Backend/Backend.Application/ApplicationConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Backend.Application.Profiles;
using Backend.Application.Services.Auth.Concretes;
using Backend.Application.Services.Auth.Interfaces;
using Backend.Application.Services.Discounts.Abstracts;
using Backend.Application.Services.Discounts.Concretes;
using Backend.Application.Services.Discounts.Interfaces;
Expand All @@ -22,9 +20,9 @@ public static class ApplicationConfiguration

public static void AddApplication(this IServiceCollection services)
{
services.AddAutoMapper(typeof(UserProfile));
services.AddAutoMapper(typeof(ProductProfile));
services.AddMediatR(cfg =>
cfg.RegisterServicesFromAssemblies(typeof(UserProfile).Assembly)
cfg.RegisterServicesFromAssemblies(typeof(ProductProfile).Assembly)
);
string authority = Env.GetString("AUTH_JWT_AUTHORITY");
string audience = Env.GetString("AUTH_JWT_AUDIENCE");
Expand Down Expand Up @@ -63,8 +61,6 @@ public static void AddApplication(this IServiceCollection services)
services.AddScoped<IComboRepository, ComboRepository>();
services.AddScoped<IProductRepository, ProductRepository>();
services.AddScoped<IImageRepository, ImageRepository>();
services.AddScoped<IUserAddressRepository, UserAddressRepository>();
services.AddScoped<IUserRepository, UserRepository>();
services.AddScoped<IPaymentTransactionRepository, PaymentTransactionRepository>();
services.AddScoped<IOrderItemRepository, OrderItemRepository>();
services.AddScoped<IInventoryService, InventoryService>();
Expand Down Expand Up @@ -93,8 +89,6 @@ public static void AddApplication(this IServiceCollection services)
]
)
);

services.AddSingleton<IJwtDecoder, JwtDecoder>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,17 @@ public async Task<string> Handle(CreateOrderCommand request, CancellationToken c
var transactionStatus = sessionWithLineItems.PaymentStatus ?? "Unknown";
var orderStatus = MapStripeStatusToOrderStatus(transactionStatus);

User? user = await _unitOfWork.UserRepository.GetUserByIdentityId(request.OrderToBeCreated.Customer.Id);


if (user == null)
{
throw new InvalidOperationException("User not found.");
}


var order = new Order
{
UserId = user.Id,
UserEmail = request.OrderToBeCreated.Customer.Email,
OrderDate = DateTime.UtcNow,
OrderStatus = orderStatus,
TotalPrice = sessionWithLineItems.AmountTotal ?? 0,
};
await _unitOfWork.OrdersRepository.AddAsync(order);

await HandleUserAddress(request.OrderToBeCreated.Customer, user.Id);


var orderItems = sessionWithLineItems.LineItems.Data.Select(item => new OrderItem
{
Expand Down Expand Up @@ -120,19 +111,4 @@ private PaymentMethod MapPaymentMethodStringToEnum(string paymentMethod)
_ => throw new ArgumentOutOfRangeException()
};
}


private async Task HandleUserAddress(CustomerDTO customer, Guid userId)
{

var newUserAddress = new UserAddress
{
UserId = userId,
Address = customer.Address,
City = customer.City,
Country = customer.Country
};

await _unitOfWork.UserAddressRepository.AddAsync(newUserAddress);
}
}

This file was deleted.

5 changes: 2 additions & 3 deletions Backend/Backend.Domain/Entities/Concretes/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ namespace Backend.Domain.Entities.Concretes;

public class Order : BaseEntity
{
public Guid UserId { get; set; }
public DateTime OrderDate { get; set; }
public OrderStatus OrderStatus { get; set; }
public double TotalPrice { get; set; }
public User User { get; set; }
public string? UserEmail { get; set; }
public PaymentTransaction PaymentTransaction { get; set; }
public ICollection<OrderItem> OrderItems { get; set; }
}
}
14 changes: 0 additions & 14 deletions Backend/Backend.Domain/Entities/Concretes/User.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Backend/Backend.Domain/Entities/Concretes/UserAddress.cs

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions Backend/Backend.Infrastructure/DAO/Concretes/UserDAO.cs

This file was deleted.

8 changes: 3 additions & 5 deletions Backend/Backend.Infrastructure/Maps/OrderMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ public void Configure(EntityTypeBuilder<Order> builder)
builder.Property(o => o.Id).ValueGeneratedOnAdd();
builder.Property(o => o.OrderDate).IsRequired();
builder.Property(o => o.TotalPrice).IsRequired();
builder.Property(o => o.UserEmail).IsRequired();


builder.HasMany(o => o.OrderItems)
.WithOne(oi => oi.Order)
.HasForeignKey(oi => oi.OrderId);

builder.HasOne(o => o.User)
.WithMany(u => u.Orders)
.HasForeignKey(o => o.UserId);

builder.HasOne(o => o.PaymentTransaction)
.WithOne(pt => pt.Order)
.HasForeignKey<PaymentTransaction>(pt => pt.OrderId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public override async Task<Order> AddAsync(Order entity)
public override async Task<IEnumerable<Order>> GetAllAsync(int page, int limit)
{
return await Context.Set<Order>()
.Include(o => o.User)
.Include(o => o.PaymentTransaction)
.Include(o => o.OrderItems)
.ThenInclude(oi => oi.Product)
Expand All @@ -32,7 +31,6 @@ public override async Task<IEnumerable<Order>> GetAllAsync(int page, int limit)
public override async Task<Order?> GetByIdAsync(Guid id)
{
return await Context.Set<Order>()
.Include(o => o.User)
.Include(o => o.PaymentTransaction)
.Include(o => o.OrderItems)
.ThenInclude(oi => oi.Product)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
namespace Backend.Infrastructure.Repositories.Concretes;

public class UnitOfWork(DbContext context, IOrderRepository ordersRepository,
IPaymentTransactionRepository paymentTransactionRepository, IUserAddressRepository userAddressRepository,
IOrderItemRepository orderItemRepository, IProductRepository productRepository, IUserRepository userRepository) : IUnitOfWork
IPaymentTransactionRepository paymentTransactionRepository,
IOrderItemRepository orderItemRepository, IProductRepository productRepository) : IUnitOfWork
{
public IOrderRepository OrdersRepository { get; } = ordersRepository;
public IPaymentTransactionRepository PaymentTransactionRepository { get; } = paymentTransactionRepository;
public IUserAddressRepository UserAddressRepository { get; } = userAddressRepository;

public IOrderItemRepository OrderItemRepository { get; } = orderItemRepository;
public IProductRepository ProductRepository { get; } = productRepository;
public IUserRepository UserRepository { get; } = userRepository;


private readonly DbContext _context = context;

Expand Down

This file was deleted.

Loading