adress und migration
This commit is contained in:
@@ -24,7 +24,6 @@ namespace Webshop.Api.Controllers.Admin
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ShippingMethodDto>> 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<ActionResult<ShippingMethodDto>> GetShippingMethodById(Guid id)
|
||||
{
|
||||
// ...
|
||||
return Ok();
|
||||
var method = await _shippingMethodService.GetByIdAsync(id);
|
||||
if (method == null) return NotFound();
|
||||
return Ok(method);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ShippingMethodDto>>> GetAllShippingMethods()
|
||||
{
|
||||
var methods = await _shippingMethodService.GetAllAsync();
|
||||
return Ok(methods);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> 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<IActionResult> DeleteShippingMethod(Guid id)
|
||||
{
|
||||
var success = await _shippingMethodService.DeleteAsync(id);
|
||||
if (!success) return NotFound();
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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");
|
||||
@@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace Webshop.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddHouseNumberAndTypeToAddress : Migration
|
||||
public partial class FinalSchema : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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",
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user