diff --git a/Webshop.Api/Controllers/Admin/AdminShippingMethodsController.cs b/Webshop.Api/Controllers/Admin/AdminShippingMethodsController.cs index 1c6dbd3..52c175c 100644 --- a/Webshop.Api/Controllers/Admin/AdminShippingMethodsController.cs +++ b/Webshop.Api/Controllers/Admin/AdminShippingMethodsController.cs @@ -24,7 +24,6 @@ namespace Webshop.Api.Controllers.Admin [HttpPost] public async Task> CreateShippingMethod([FromBody] ShippingMethodDto shippingMethodDto) { - // Implementierung im AdminShippingMethodService var createdMethod = await _shippingMethodService.CreateAsync(shippingMethodDto); return CreatedAtAction(nameof(GetShippingMethodById), new { id = createdMethod.Id }, createdMethod); } @@ -32,8 +31,33 @@ namespace Webshop.Api.Controllers.Admin [HttpGet("{id}")] public async Task> GetShippingMethodById(Guid id) { - // ... - return Ok(); + var method = await _shippingMethodService.GetByIdAsync(id); + if (method == null) return NotFound(); + return Ok(method); + } + + [HttpGet] + public async Task>> GetAllShippingMethods() + { + var methods = await _shippingMethodService.GetAllAsync(); + return Ok(methods); + } + + [HttpPut("{id}")] + public async Task UpdateShippingMethod(Guid id, [FromBody] ShippingMethodDto shippingMethodDto) + { + if (id != shippingMethodDto.Id) return BadRequest(); + var success = await _shippingMethodService.UpdateAsync(shippingMethodDto); + if (!success) return NotFound(); + return NoContent(); + } + + [HttpDelete("{id}")] + public async Task DeleteShippingMethod(Guid id) + { + var success = await _shippingMethodService.DeleteAsync(id); + if (!success) return NotFound(); + return NoContent(); } } } \ No newline at end of file diff --git a/Webshop.Api/Controllers/Customers/AddressesController.cs b/Webshop.Api/Controllers/Customers/AddressesController.cs index 649b2d1..1b61530 100644 --- a/Webshop.Api/Controllers/Customers/AddressesController.cs +++ b/Webshop.Api/Controllers/Customers/AddressesController.cs @@ -38,7 +38,6 @@ namespace Webshop.Api.Controllers.Customer if (createdAddress == null) return BadRequest(new { Message = errorMessage }); - // Annahme: Es gibt eine GetMyAddressById-Methode return CreatedAtAction(nameof(GetMyAddresses), new { id = createdAddress.Id }, createdAddress); } } diff --git a/Webshop.Infrastructure/Migrations/20250801073120_AddHouseNumberAndTypeToAddress.Designer.cs b/Webshop.Infrastructure/Migrations/20250801114205_FinalSchema.Designer.cs similarity index 99% rename from Webshop.Infrastructure/Migrations/20250801073120_AddHouseNumberAndTypeToAddress.Designer.cs rename to Webshop.Infrastructure/Migrations/20250801114205_FinalSchema.Designer.cs index 2d418cf..865da9a 100644 --- a/Webshop.Infrastructure/Migrations/20250801073120_AddHouseNumberAndTypeToAddress.Designer.cs +++ b/Webshop.Infrastructure/Migrations/20250801114205_FinalSchema.Designer.cs @@ -12,8 +12,8 @@ using Webshop.Infrastructure.Data; namespace Webshop.Infrastructure.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20250801073120_AddHouseNumberAndTypeToAddress")] - partial class AddHouseNumberAndTypeToAddress + [Migration("20250801114205_FinalSchema")] + partial class FinalSchema { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -1224,10 +1224,10 @@ namespace Webshop.Infrastructure.Migrations modelBuilder.Entity("Webshop.Domain.Entities.Product", b => { - b.Navigation("Productcategorys"); - b.Navigation("ProductDiscounts"); + b.Navigation("Productcategorys"); + b.Navigation("Reviews"); b.Navigation("Variants"); diff --git a/Webshop.Infrastructure/Migrations/20250801073120_AddHouseNumberAndTypeToAddress.cs b/Webshop.Infrastructure/Migrations/20250801114205_FinalSchema.cs similarity index 99% rename from Webshop.Infrastructure/Migrations/20250801073120_AddHouseNumberAndTypeToAddress.cs rename to Webshop.Infrastructure/Migrations/20250801114205_FinalSchema.cs index b450b72..58701a2 100644 --- a/Webshop.Infrastructure/Migrations/20250801073120_AddHouseNumberAndTypeToAddress.cs +++ b/Webshop.Infrastructure/Migrations/20250801114205_FinalSchema.cs @@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Webshop.Infrastructure.Migrations { /// - public partial class AddHouseNumberAndTypeToAddress : Migration + public partial class FinalSchema : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -163,18 +163,18 @@ namespace Webshop.Infrastructure.Migrations constraints: table => { table.PrimaryKey("PK_CategoryDiscounts", x => new { x.CategoryId, x.DiscountId }); - table.ForeignKey( - name: "FK_CategoryDiscounts_categorys_CategoryId", - column: x => x.CategoryId, - principalTable: "categorys", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_CategoryDiscounts_Discounts_DiscountId", column: x => x.DiscountId, principalTable: "Discounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CategoryDiscounts_categorys_CategoryId", + column: x => x.CategoryId, + principalTable: "categorys", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -459,18 +459,18 @@ namespace Webshop.Infrastructure.Migrations constraints: table => { table.PrimaryKey("PK_Productcategorys", x => new { x.ProductId, x.CategoryId }); - table.ForeignKey( - name: "FK_Productcategorys_categorys_CategoryId", - column: x => x.CategoryId, - principalTable: "categorys", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Productcategorys_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Productcategorys_categorys_CategoryId", + column: x => x.CategoryId, + principalTable: "categorys", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -593,6 +593,11 @@ namespace Webshop.Infrastructure.Migrations table: "Addresses", column: "CustomerId"); + migrationBuilder.CreateIndex( + name: "IX_CategoryDiscounts_DiscountId", + table: "CategoryDiscounts", + column: "DiscountId"); + migrationBuilder.CreateIndex( name: "IX_categorys_ParentCategoryId", table: "categorys", @@ -604,11 +609,6 @@ namespace Webshop.Infrastructure.Migrations column: "Slug", unique: true); - migrationBuilder.CreateIndex( - name: "IX_CategoryDiscounts_DiscountId", - table: "CategoryDiscounts", - column: "DiscountId"); - migrationBuilder.CreateIndex( name: "IX_Customers_AspNetUserId", table: "Customers", diff --git a/Webshop.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs b/Webshop.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs index 3840db8..09082f2 100644 --- a/Webshop.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Webshop.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1221,10 +1221,10 @@ namespace Webshop.Infrastructure.Migrations modelBuilder.Entity("Webshop.Domain.Entities.Product", b => { - b.Navigation("Productcategorys"); - b.Navigation("ProductDiscounts"); + b.Navigation("Productcategorys"); + b.Navigation("Reviews"); b.Navigation("Variants"); diff --git a/Webshop.Infrastructure/Repositories/AdressRepository.cs b/Webshop.Infrastructure/Repositories/AddressRepository.cs similarity index 100% rename from Webshop.Infrastructure/Repositories/AdressRepository.cs rename to Webshop.Infrastructure/Repositories/AddressRepository.cs