Skip to content

Commit

Permalink
Fixed type in PosPurchase property and ran formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
TTA777 committed Sep 21, 2023
1 parent e141cf7 commit 8d6f29d
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 17 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

Expand All @@ -14,7 +14,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
columns: table => new
{
PurchaseId = table.Column<int>(type: "int", nullable: false),
BastiaInitials = table.Column<string>(type: "nvarchar(max)", nullable: false)
BaristaInitials = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
// Create new vouchers for purchases where the same voucher have been used to issue multiple purchase
migrationBuilder.Sql("insert into Vouchers (Code, DateCreated, DateUsed, Description, Requester, Product_Id, User_Id, PurchaseId) select Purchases.OrderId + '-' + cast(Purchases.Id as varchar), Purchases.DateCreated, Purchases.DateCreated, 'Creation of extra vouchers for purchases without references', 'AnalogIO', Purchases.ProductId, Purchases.PurchasedBy_Id, Id from Purchases where Type = 'Voucher' and Id not in (select PurchaseId from Vouchers where PurchaseId is not null)");
// Insert data to the new Pos table
migrationBuilder.Sql("insert into PosPurchases (PurchaseId, BastiaInitials) select Id, TransactionId from Purchases where OrderId like 'Analog'");
migrationBuilder.Sql("insert into PosPurchases (PurchaseId, BaristaInitials) select Id, TransactionId from Purchases where OrderId like 'Analog'");
}

protected override void Down(MigrationBuilder migrationBuilder)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <auto-generated />
// <auto-generated />
using System;
using CoffeeCard.Library.Persistence;
using Microsoft.EntityFrameworkCore;
Expand Down Expand Up @@ -49,7 +49,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<int>("PurchaseId")
.HasColumnType("int");

b.Property<string>("BastiaInitials")
b.Property<string>("BaristaInitials")
.IsRequired()
.HasColumnType("nvarchar(max)");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ public enum PaymentType
FreePurchase
}

public static class PaymentTypeExtension{
public static class PaymentTypeExtension
{
/// Converts the payment type to a corresponding PurchasType
public static PurchaseType toPurchaseType(this PaymentType paymentType){
return paymentType switch {
public static PurchaseType toPurchaseType(this PaymentType paymentType)
{
return paymentType switch
{
PaymentType.MobilePay => PurchaseType.MobilePayV2,
PaymentType.FreePurchase => PurchaseType.Free,
_ => throw new ArgumentException("Unknown enum given to PaymentTypeExtension"),
Expand Down
4 changes: 4 additions & 0 deletions coffeecard/CoffeeCard.Models/Entities/PosPurchase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

namespace CoffeeCard.Models.Entities
{
/// Represents a purchase issued by a barista at the point of sale in the cafe
public class PosPurhase{
/// The foreign key linking to a purchase
[Key, ForeignKey(nameof(Purchase))]
public int PurchaseId { get; set; }
/// The purchase that was issued by the barista
public virtual Purchase Purchase { get; set; }
/// The ITU intials of the issueing barista
public string BastiaInitials {get; set; }
}
}
2 changes: 1 addition & 1 deletion coffeecard/CoffeeCard.Models/Entities/Purchase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class Purchase

/// The type of purchase e.g. MobilePayV1, Free
public PurchaseType Type { get; set; }

[Column(name: "PurchasedBy_Id")]
public int PurchasedById { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions coffeecard/CoffeeCard.Models/Entities/PurchaseType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public enum PurchaseType
Voucher,
/// A purchase issued by the user redeeming a product costing 0
Free,
/// Purchases performed in the cafe, for users without in-app payment options
PointOfSale,
/// Purchases performed in the cafe, for users without in-app payment options
PointOfSale,
}
}

0 comments on commit 8d6f29d

Please sign in to comment.