Compare commits

...

3 Commits

Author SHA1 Message Date
18fc3fb3f2 Add default value for PaymentType in Walk entity
This commit introduces a default value of `1` for the `PaymentType` property in the `Walk` entity. The `SqlDbContextModelSnapshot.cs` is updated to reflect this change, and the `SqlDbContext.cs` is configured to set the default value to `WalkPaymentType.MangoPay`. A new migration class `Walk_PaymentType_DefaultSet` is created to apply these changes to the database schema, ensuring that new records in the `Walks` table will have a default `PaymentType` of `1`.
2025-09-15 15:35:37 +02:00
fafbc55732 Change authorization policy for EditCustomer method
Updated the authorization policy for the `EditCustomer` method in the `AdvertisementController` to allow access only to users with the "Customer" role, replacing the previous "Power User" role requirement.
2025-08-11 18:01:46 +02:00
555273aed1 Make PaymentType nullable and handle null cases
Updated the PaymentType property in PublicWalkRequestAcceptDto and WalkCreateDto to be nullable.
Modified ApiWalksController to safely assign PaymentType, using a default value when null to prevent runtime errors.
2025-08-06 16:46:32 +02:00
8 changed files with 9526 additions and 7 deletions

View File

@ -40,6 +40,6 @@ namespace gehGassi.Dto.Walks
/// <summary> /// <summary>
/// Zahlungsart für den Walk /// Zahlungsart für den Walk
/// </summary> /// </summary>
public WalkPaymentTypeDto PaymentType { get; set; } public WalkPaymentTypeDto? PaymentType { get; set; }
} }
} }

View File

@ -105,6 +105,6 @@ namespace gehGassi.Dto.Walks
/// <summary> /// <summary>
/// Zahlungsart für den Walk /// Zahlungsart für den Walk
/// </summary> /// </summary>
public WalkPaymentTypeDto PaymentType { get; set; } public WalkPaymentTypeDto? PaymentType { get; set; }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace gehGassi.Persistence.Migrations
{
/// <inheritdoc />
public partial class Walk_PaymentType_DefaultSet : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "PaymentType",
table: "Walks",
type: "int",
nullable: false,
defaultValue: 1,
oldClrType: typeof(int),
oldType: "int");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "PaymentType",
table: "Walks",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int",
oldDefaultValue: 1);
}
}
}

View File

@ -7819,7 +7819,9 @@ namespace gehGassi.Persistence.Migrations
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("PaymentType") b.Property<int>("PaymentType")
.HasColumnType("int"); .ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(1);
b.Property<Point>("PickupLocation") b.Property<Point>("PickupLocation")
.HasColumnType("geography"); .HasColumnType("geography");

View File

@ -383,6 +383,7 @@ namespace gehGassi.Persistence
builder.Entity<Walk>().OwnsOne(p => p.ReturnAddress); builder.Entity<Walk>().OwnsOne(p => p.ReturnAddress);
builder.Entity<Walk>().Property(c => c.Price).HasColumnType("decimal(18,2)"); builder.Entity<Walk>().Property(c => c.Price).HasColumnType("decimal(18,2)");
builder.Entity<Walk>().Property(c => c.VoucherAmmount).HasColumnType("decimal(18,2)"); builder.Entity<Walk>().Property(c => c.VoucherAmmount).HasColumnType("decimal(18,2)");
builder.Entity<Walk>().Property(c => c.PaymentType).HasDefaultValue(WalkPaymentType.MangoPay);
builder.Entity<WalkComplaint>().HasIndex(c => c.Index); builder.Entity<WalkComplaint>().HasIndex(c => c.Index);
builder.Entity<WalkComplaint>().HasOne<Walk>().WithMany().HasForeignKey(c => c.WalkId).OnDelete(DeleteBehavior.Cascade); builder.Entity<WalkComplaint>().HasOne<Walk>().WithMany().HasForeignKey(c => c.WalkId).OnDelete(DeleteBehavior.Cascade);

View File

@ -776,7 +776,7 @@ namespace gehGassi.Web.Controllers
/// </summary> /// </summary>
/// <param name="model">Model</param> /// <param name="model">Model</param>
/// <returns>Json</returns> /// <returns>Json</returns>
[Authorize(Policy = Policies.PowerUserOnly)] [Authorize(Policy = Policies.CustomerOnly)]
[HasPermission(Permission.AdvertisementsManage, Permission.AdvertisementsEdit)] [HasPermission(Permission.AdvertisementsManage, Permission.AdvertisementsEdit)]
[CustomerAuthorize("CustomerId")] [CustomerAuthorize("CustomerId")]
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]

View File

@ -1039,7 +1039,7 @@ namespace gehGassi.Web.Controllers.Api
walk.CompletedInfo = string.Empty; walk.CompletedInfo = string.Empty;
walk.Defactation = false; walk.Defactation = false;
walk.PaymentStatus = PaymentStatus.Pending; walk.PaymentStatus = PaymentStatus.Pending;
walk.PaymentType = (WalkPaymentType)model.PaymentType; walk.PaymentType = model.PaymentType != null ? (WalkPaymentType)model.PaymentType : WalkPaymentType.MangoPay;
walk.UpdatedAt = DateTimeOffset.UtcNow; walk.UpdatedAt = DateTimeOffset.UtcNow;
walk.Created = DateTimeOffset.UtcNow; walk.Created = DateTimeOffset.UtcNow;
@ -3630,7 +3630,7 @@ namespace gehGassi.Web.Controllers.Api
walk.CompletedInfo = string.Empty; walk.CompletedInfo = string.Empty;
walk.Defactation = false; walk.Defactation = false;
walk.PaymentStatus = PaymentStatus.Pending; walk.PaymentStatus = PaymentStatus.Pending;
walk.PaymentType = (WalkPaymentType)model.PaymentType; walk.PaymentType = model.PaymentType != null ? (WalkPaymentType)model.PaymentType : WalkPaymentType.MangoPay;
walk.UpdatedAt = DateTimeOffset.UtcNow; walk.UpdatedAt = DateTimeOffset.UtcNow;
walk.Created = DateTimeOffset.UtcNow; walk.Created = DateTimeOffset.UtcNow;
@ -3810,7 +3810,7 @@ namespace gehGassi.Web.Controllers.Api
walk.CompletedInfo = string.Empty; walk.CompletedInfo = string.Empty;
walk.Defactation = false; walk.Defactation = false;
walk.PaymentStatus = PaymentStatus.None; walk.PaymentStatus = PaymentStatus.None;
walk.PaymentType = (WalkPaymentType)model.PaymentType; walk.PaymentType = model.PaymentType != null ? (WalkPaymentType)model.PaymentType : WalkPaymentType.MangoPay;
walk.UpdatedAt = DateTimeOffset.UtcNow; walk.UpdatedAt = DateTimeOffset.UtcNow;
walk.Created = DateTimeOffset.UtcNow; walk.Created = DateTimeOffset.UtcNow;