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 Jul 26, 2023
1 parent 9c9e15b commit 4ee16c6
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 22 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 Down Expand Up @@ -31,7 +31,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
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 @@ -52,7 +52,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);

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
15 changes: 10 additions & 5 deletions coffeecard/CoffeeCard.Models/Entities/PosPurchase.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
namespace CoffeeCard.Models.Entities
{
public class PosPurhase{
public int Id { get; set; }
public Purchase Purchase { get; set; }
public string BastiaInitials {get; set; }
}
/// Represents a purchase issued by a barista at the point of sale in the cafe
public class PosPurhase
{
/// Primary key
public int Id { get; set; }
/// The purchase that was issued by the barista
public Purchase Purchase { get; set; }
/// The ITU intials of the issueing barista
public string BaristaInitials { 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 4ee16c6

Please sign in to comment.