diff --git a/KebPOS.sln b/KebPOS.sln deleted file mode 100644 index 8648642..0000000 --- a/KebPOS.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KebPOS", "KebPOS\KebPOS.csproj", "{5C4C4DC9-76FE-4640-AE21-7E54B7673FF9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KebPOSTests", "KebPOSTests\KebPOSTests.csproj", "{88CE3F40-011D-4C8D-857F-5D661969C1EB}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5C4C4DC9-76FE-4640-AE21-7E54B7673FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5C4C4DC9-76FE-4640-AE21-7E54B7673FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5C4C4DC9-76FE-4640-AE21-7E54B7673FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5C4C4DC9-76FE-4640-AE21-7E54B7673FF9}.Release|Any CPU.Build.0 = Release|Any CPU - {88CE3F40-011D-4C8D-857F-5D661969C1EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {88CE3F40-011D-4C8D-857F-5D661969C1EB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {88CE3F40-011D-4C8D-857F-5D661969C1EB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {88CE3F40-011D-4C8D-857F-5D661969C1EB}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/KebPOS/Appsettings.json b/KebPOS/Appsettings.json deleted file mode 100644 index 077404a..0000000 --- a/KebPOS/Appsettings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} \ No newline at end of file diff --git a/KebPOS/DbContexts/KebabContext.cs b/KebPOS/DbContexts/KebabContext.cs deleted file mode 100644 index 9e9056d..0000000 --- a/KebPOS/DbContexts/KebabContext.cs +++ /dev/null @@ -1,37 +0,0 @@ -using KebPOS.Models; -using KebPOS.Services; -using Microsoft.EntityFrameworkCore; - -namespace KebPOS.DbContexts; - -internal class KebabContext : DbContext -{ - public DbSet Orders { get; set; } - public DbSet Products { get; set; } - public DbSet OrderProducts { get; set; } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - // Data source to be replaced with config connection string. - string projPath = Path.GetFullPath(@"C:\\Users\\sipah\\Desktop\\serdar\\projeler\\pointofsle\\CONSOLE.PointOfSale\\KebPOS\\"); - // optionsBuilder.UseSqlite($"C:\\Users\\sipah\\Desktop\\serdar\\projeler\\pointofsle\\CONSOLE.PointOfSale\\KebPOS\\Kebab.db"); - optionsBuilder.UseSqlite($"Data Source=Kebab.db;"); - } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity() - .HasKey(op => new { op.OrderId, op.ProductId }); - modelBuilder.Entity() - .HasOne(op => op.Order) - .WithMany(o => o.OrderProducts) - .HasForeignKey(op => op.OrderId); - modelBuilder.Entity() - .HasOne(op => op.Product) - .WithMany(p => p.OrderProducts) - .HasForeignKey(op => op.ProductId); - - modelBuilder.Entity() - .HasData(ProductService.GetProducts()); - } -} diff --git a/KebPOS/Kebab.db-shm b/KebPOS/Kebab.db-shm deleted file mode 100644 index 5bc5c6b..0000000 Binary files a/KebPOS/Kebab.db-shm and /dev/null differ diff --git a/KebPOS/Kebab.db-wal b/KebPOS/Kebab.db-wal deleted file mode 100644 index 476501f..0000000 Binary files a/KebPOS/Kebab.db-wal and /dev/null differ diff --git a/KebPOS/KebabController.cs b/KebPOS/KebabController.cs deleted file mode 100644 index f5639ed..0000000 --- a/KebPOS/KebabController.cs +++ /dev/null @@ -1,74 +0,0 @@ -using KebPOS.DbContexts; -using KebPOS.Models; -using Microsoft.EntityFrameworkCore; - -namespace KebPOS; - -public class KebabController -{ - public void UpdateProductName(Product product, string newProductName) - { - using var db = new KebabContext(); - product.Name = newProductName; - db.Entry(product).State = EntityState.Modified; - db.SaveChanges(); - } - - public void UpdateProductPrice(Product product, decimal newPrice) - { - using var db = new KebabContext(); - product.Price = newPrice; - db.Entry(product).State = EntityState.Modified; - db.SaveChanges(); - } - - public void UpdateProductDescription(Product product, string newProductDescription) - { - using var db = new KebabContext(); - product.Description = newProductDescription; - db.Entry(product).State = EntityState.Modified; - db.SaveChanges(); - } - public List GetProducts() - { - using var db = new KebabContext(); - return db.Products.OrderBy(x => x.Name).ToList(); - } - - public List GetOrders() - { - using var db = new KebabContext(); - return db.Orders.OrderBy(x => x.OrderDate).Include(o => o.OrderProducts).ThenInclude(p => p.Product).ToList(); - } - - public void AddOrders(List orderProductsList) - { - using var db = new KebabContext(); - - db.OrderProducts.AddRange(orderProductsList); - - db.SaveChanges(); - } - - public void RemoveOrder(Order toBeRemoved) // Burayi kodladın takip et: You coded here, follow - { - using var db = new KebabContext(); - db.Orders.Remove(toBeRemoved); - db.SaveChanges(); - } - - internal static void AddProduct(Product product) - { - try - { - using var db = new KebabContext(); - db.Add(product); - db.SaveChanges(); - Console.WriteLine("Product added successfully!"); - } - catch (Exception ex) - { - Console.WriteLine($"Error adding product to the database: {ex.Message}"); - } - } -} diff --git a/KebPOS/Migrations/20221127010222_InitialMigration.Designer.cs b/KebPOS/Migrations/20221127010222_InitialMigration.Designer.cs deleted file mode 100644 index df75fad..0000000 --- a/KebPOS/Migrations/20221127010222_InitialMigration.Designer.cs +++ /dev/null @@ -1,276 +0,0 @@ -// -using System; -using KebPOS.DbContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace KebPOS.Migrations -{ - [DbContext(typeof(KebabContext))] - [Migration("20221127010222_InitialMigration")] - partial class InitialMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.0"); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("OrderDate") - .HasColumnType("TEXT"); - - b.Property("TotalPrice") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Orders"); - - b.HasData( - new - { - Id = 1, - OrderDate = new DateTime(2022, 11, 27, 1, 2, 22, 751, DateTimeKind.Utc).AddTicks(3162), - TotalPrice = 11.81m - }, - new - { - Id = 2, - OrderDate = new DateTime(2022, 11, 27, 1, 6, 22, 751, DateTimeKind.Utc).AddTicks(3165), - TotalPrice = 6.86m - }, - new - { - Id = 3, - OrderDate = new DateTime(2022, 11, 27, 1, 11, 22, 751, DateTimeKind.Utc).AddTicks(3172), - TotalPrice = 7.75m - }); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.Property("OrderId") - .HasColumnType("INTEGER"); - - b.Property("ProductId") - .HasColumnType("INTEGER"); - - b.HasKey("OrderId", "ProductId"); - - b.HasIndex("ProductId"); - - b.ToTable("OrderProducts"); - - b.HasData( - new - { - OrderId = 1, - ProductId = 1 - }, - new - { - OrderId = 1, - ProductId = 5 - }, - new - { - OrderId = 1, - ProductId = 9 - }, - new - { - OrderId = 2, - ProductId = 1 - }, - new - { - OrderId = 2, - ProductId = 4 - }, - new - { - OrderId = 3, - ProductId = 6 - }, - new - { - OrderId = 3, - ProductId = 3 - }); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Price") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Products"); - - b.HasData( - new - { - Id = 1, - Description = " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \r\n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \r\n You can add other veggies also.", - Name = "Yogurt Kebab", - Price = 3.49m - }, - new - { - Id = 2, - Description = " This Kebab is one among all the most popular and delicious Kebabs. \r\n The special part of this Kebab is that they are grilled on the skewer. \r\n Here the word shish means skewer. And the word Kebab stands for meat. \r\n This dish comes under the category of side dish. \r\n This dish is very famous in Turkey. \r\n Just imagine the taste of Turkish dish with an Indian tadka. \r\n These are most popular of all Kebabs. \r\n Steamed vegetables and salads are served along with these Kebabs.", - Name = "Shish Kebab", - Price = 4.19m - }, - new - { - Id = 3, - Description = "Another name of this Kebab is rotating Kebab. \r\nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \r\nThis comes under the category of popular fast food loved by all. \r\nThe Kebab is made of lamb’s meat. \r\nThe special taste of Kebab is due to its cooking style. \r\nThe Kebabs are cooked slowly so that the meat juice could spread its flavor.", - Name = "Doner Kebab", - Price = 3.39m - }, - new - { - Id = 4, - Description = " Kathi Kebabs are very famous as they are made using tandoor. \r\n This is the most popular Indian dish made using tandoor. \r\n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \r\n This Kebab is a very wonderful snack to have. \r\n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \r\n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also.", - Name = "Kathi Kebab", - Price = 3.37m - }, - new - { - Id = 5, - Description = " Chapli Kebabs are a very famous dish of Pakistani cuisine. \r\n This minced meat has a special taste. \r\n The Kebab is made using beef. \r\n This Pakistani dish with an Indian special tadka is all you need to have.", - Name = "Chapli Kebab", - Price = 4.33m - }, - new - { - Id = 6, - Description = " Burrah Kebabs are also known as barrah Kebab. \r\n The Kebab is made up of beef and lots and lots of spices. \r\n This Kebab is very famous Kebab of Mughlai cuisine. \r\n This dish comes under the heavy meal category. \r\n It majorly includes larger pieces of meat. \r\n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish.", - Name = "Burrah Kebab", - Price = 4.36m - }, - new - { - Id = 7, - Description = " This is an Irani dish with an Indian tadka. \r\n This is, in fact, national food of Iran. \r\n The dish is basic but yummy in taste. \r\n They are always served with buttered rice. \r\n Most of the people prefer doogh which is a yogurt drink with this Kebab. \r\n The dish comes under the category of the side dish, but the taste of the dish is very special.", - Name = "Chelow Kebab", - Price = 4.29m - }, - new - { - Id = 8, - Description = " The name of the Kebab is testi Kebab, and here the word testi means jug. \r\n Yes, the Kebab is served in a pot. \r\n You can use dough or foil to cover the pot. \r\n The pot is broken while eating. \r\n We all know how special the taste of “matke ka pani” is. \r\n Similarly, the taste of matka Kebab is very special.", - Name = "Testi Kebab", - Price = 3.69m - }, - new - { - Id = 9, - Description = " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \r\n The dish is very yummy.", - Name = "Dill Salmon Kebab", - Price = 3.99m - }, - new - { - Id = 10, - Description = " Lamb Kebabs are very easy to make. \r\n What all you need to do is marinate the mince meat with all the spices. \r\n You can add egg also just to enhance the taste of Kebab.", - Name = "Lamb Kebab", - Price = 3.79m - }, - new - { - Id = 11, - Description = "A freshly pulled shot of espresso layered with steamed whole milk and thick rich foam to offer a luxurious velvety texture and complex aroma.", - Name = "Cappuccino", - Price = 1.49m - }, - new - { - Id = 12, - Description = "Red Bull is a utility drink to be taken against mental or physical weariness or exhaustion.", - Name = "Red Bull", - Price = 1.87m - }, - new - { - Id = 13, - Description = "Coca-Cola is a carbonated, sweetened soft drink and is the world's best-selling drink. A popular nickname for Coca-Cola is Coke.", - Name = "Coca Cola", - Price = 0.93m - }, - new - { - Id = 14, - Description = "Crisp, refreshing and clean-tasting, Sprite is a lemon and lime-flavoured soft drink.", - Name = "Sprite", - Price = 1.99m - }, - new - { - Id = 15, - Description = "BonAqua is a high-quality drinking water.", - Name = "Bonaqua Sparkling", - Price = 1.24m - }); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.HasOne("KebPOS.Models.Order", "Order") - .WithMany("OrderProducts") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("KebPOS.Models.Product", "Product") - .WithMany("OrderProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Navigation("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Navigation("OrderProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/KebPOS/Migrations/20221127010222_InitialMigration.cs b/KebPOS/Migrations/20221127010222_InitialMigration.cs deleted file mode 100644 index 5d4ae92..0000000 --- a/KebPOS/Migrations/20221127010222_InitialMigration.cs +++ /dev/null @@ -1,133 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace KebPOS.Migrations -{ - /// - public partial class InitialMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - OrderDate = table.Column(type: "TEXT", nullable: false), - TotalPrice = table.Column(type: "TEXT", precision: 18, scale: 2, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Orders", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Products", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Name = table.Column(type: "TEXT", maxLength: 100, nullable: false), - Description = table.Column(type: "TEXT", maxLength: 200, nullable: false), - Price = table.Column(type: "TEXT", precision: 18, scale: 2, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Products", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "OrderProducts", - columns: table => new - { - OrderId = table.Column(type: "INTEGER", nullable: false), - ProductId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_OrderProducts", x => new { x.OrderId, x.ProductId }); - table.ForeignKey( - name: "FK_OrderProducts_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_OrderProducts_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.InsertData( - table: "Orders", - columns: new[] { "Id", "OrderDate", "TotalPrice" }, - values: new object[,] - { - { 1, new DateTime(2022, 11, 27, 1, 2, 22, 751, DateTimeKind.Utc).AddTicks(3162), 11.81m }, - { 2, new DateTime(2022, 11, 27, 1, 6, 22, 751, DateTimeKind.Utc).AddTicks(3165), 6.86m }, - { 3, new DateTime(2022, 11, 27, 1, 11, 22, 751, DateTimeKind.Utc).AddTicks(3172), 7.75m } - }); - - migrationBuilder.InsertData( - table: "Products", - columns: new[] { "Id", "Description", "Name", "Price" }, - values: new object[,] - { - { 1, " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \r\n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \r\n You can add other veggies also.", "Yogurt Kebab", 3.49m }, - { 2, " This Kebab is one among all the most popular and delicious Kebabs. \r\n The special part of this Kebab is that they are grilled on the skewer. \r\n Here the word shish means skewer. And the word Kebab stands for meat. \r\n This dish comes under the category of side dish. \r\n This dish is very famous in Turkey. \r\n Just imagine the taste of Turkish dish with an Indian tadka. \r\n These are most popular of all Kebabs. \r\n Steamed vegetables and salads are served along with these Kebabs.", "Shish Kebab", 4.19m }, - { 3, "Another name of this Kebab is rotating Kebab. \r\nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \r\nThis comes under the category of popular fast food loved by all. \r\nThe Kebab is made of lamb’s meat. \r\nThe special taste of Kebab is due to its cooking style. \r\nThe Kebabs are cooked slowly so that the meat juice could spread its flavor.", "Doner Kebab", 3.39m }, - { 4, " Kathi Kebabs are very famous as they are made using tandoor. \r\n This is the most popular Indian dish made using tandoor. \r\n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \r\n This Kebab is a very wonderful snack to have. \r\n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \r\n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also.", "Kathi Kebab", 3.37m }, - { 5, " Chapli Kebabs are a very famous dish of Pakistani cuisine. \r\n This minced meat has a special taste. \r\n The Kebab is made using beef. \r\n This Pakistani dish with an Indian special tadka is all you need to have.", "Chapli Kebab", 4.33m }, - { 6, " Burrah Kebabs are also known as barrah Kebab. \r\n The Kebab is made up of beef and lots and lots of spices. \r\n This Kebab is very famous Kebab of Mughlai cuisine. \r\n This dish comes under the heavy meal category. \r\n It majorly includes larger pieces of meat. \r\n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish.", "Burrah Kebab", 4.36m }, - { 7, " This is an Irani dish with an Indian tadka. \r\n This is, in fact, national food of Iran. \r\n The dish is basic but yummy in taste. \r\n They are always served with buttered rice. \r\n Most of the people prefer doogh which is a yogurt drink with this Kebab. \r\n The dish comes under the category of the side dish, but the taste of the dish is very special.", "Chelow Kebab", 4.29m }, - { 8, " The name of the Kebab is testi Kebab, and here the word testi means jug. \r\n Yes, the Kebab is served in a pot. \r\n You can use dough or foil to cover the pot. \r\n The pot is broken while eating. \r\n We all know how special the taste of “matke ka pani” is. \r\n Similarly, the taste of matka Kebab is very special.", "Testi Kebab", 3.69m }, - { 9, " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \r\n The dish is very yummy.", "Dill Salmon Kebab", 3.99m }, - { 10, " Lamb Kebabs are very easy to make. \r\n What all you need to do is marinate the mince meat with all the spices. \r\n You can add egg also just to enhance the taste of Kebab.", "Lamb Kebab", 3.79m }, - { 11, "A freshly pulled shot of espresso layered with steamed whole milk and thick rich foam to offer a luxurious velvety texture and complex aroma.", "Cappuccino", 1.49m }, - { 12, "Red Bull is a utility drink to be taken against mental or physical weariness or exhaustion.", "Red Bull", 1.87m }, - { 13, "Coca-Cola is a carbonated, sweetened soft drink and is the world's best-selling drink. A popular nickname for Coca-Cola is Coke.", "Coca Cola", 0.93m }, - { 14, "Crisp, refreshing and clean-tasting, Sprite is a lemon and lime-flavoured soft drink.", "Sprite", 1.99m }, - { 15, "BonAqua is a high-quality drinking water.", "Bonaqua Sparkling", 1.24m } - }); - - migrationBuilder.InsertData( - table: "OrderProducts", - columns: new[] { "OrderId", "ProductId" }, - values: new object[,] - { - { 1, 1 }, - { 1, 5 }, - { 1, 9 }, - { 2, 1 }, - { 2, 4 }, - { 3, 3 }, - { 3, 6 } - }); - - migrationBuilder.CreateIndex( - name: "IX_OrderProducts_ProductId", - table: "OrderProducts", - column: "ProductId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "OrderProducts"); - - migrationBuilder.DropTable( - name: "Orders"); - - migrationBuilder.DropTable( - name: "Products"); - } - } -} diff --git a/KebPOS/Migrations/20221127063403_orderModels.Designer.cs b/KebPOS/Migrations/20221127063403_orderModels.Designer.cs deleted file mode 100644 index f36f4f4..0000000 --- a/KebPOS/Migrations/20221127063403_orderModels.Designer.cs +++ /dev/null @@ -1,276 +0,0 @@ -// -using System; -using KebPOS.DbContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace KebPOS.Migrations -{ - [DbContext(typeof(KebabContext))] - [Migration("20221127063403_orderModels")] - partial class orderModels - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.0"); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("OrderDate") - .HasColumnType("TEXT"); - - b.Property("TotalPrice") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Orders"); - - b.HasData( - new - { - Id = 1, - OrderDate = new DateTime(2022, 11, 27, 6, 34, 3, 450, DateTimeKind.Utc).AddTicks(638), - TotalPrice = 11.81m - }, - new - { - Id = 2, - OrderDate = new DateTime(2022, 11, 27, 6, 38, 3, 450, DateTimeKind.Utc).AddTicks(645), - TotalPrice = 6.86m - }, - new - { - Id = 3, - OrderDate = new DateTime(2022, 11, 27, 6, 43, 3, 450, DateTimeKind.Utc).AddTicks(655), - TotalPrice = 7.75m - }); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.Property("OrderId") - .HasColumnType("INTEGER"); - - b.Property("ProductId") - .HasColumnType("INTEGER"); - - b.HasKey("OrderId", "ProductId"); - - b.HasIndex("ProductId"); - - b.ToTable("OrderProducts"); - - b.HasData( - new - { - OrderId = 1, - ProductId = 1 - }, - new - { - OrderId = 1, - ProductId = 5 - }, - new - { - OrderId = 1, - ProductId = 9 - }, - new - { - OrderId = 2, - ProductId = 1 - }, - new - { - OrderId = 2, - ProductId = 4 - }, - new - { - OrderId = 3, - ProductId = 6 - }, - new - { - OrderId = 3, - ProductId = 3 - }); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Price") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Products"); - - b.HasData( - new - { - Id = 1, - Description = " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \r\n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \r\n You can add other veggies also.", - Name = "Yogurt Kebab", - Price = 3.49m - }, - new - { - Id = 2, - Description = " This Kebab is one among all the most popular and delicious Kebabs. \r\n The special part of this Kebab is that they are grilled on the skewer. \r\n Here the word shish means skewer. And the word Kebab stands for meat. \r\n This dish comes under the category of side dish. \r\n This dish is very famous in Turkey. \r\n Just imagine the taste of Turkish dish with an Indian tadka. \r\n These are most popular of all Kebabs. \r\n Steamed vegetables and salads are served along with these Kebabs.", - Name = "Shish Kebab", - Price = 4.19m - }, - new - { - Id = 3, - Description = "Another name of this Kebab is rotating Kebab. \r\nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \r\nThis comes under the category of popular fast food loved by all. \r\nThe Kebab is made of lamb’s meat. \r\nThe special taste of Kebab is due to its cooking style. \r\nThe Kebabs are cooked slowly so that the meat juice could spread its flavor.", - Name = "Doner Kebab", - Price = 3.39m - }, - new - { - Id = 4, - Description = " Kathi Kebabs are very famous as they are made using tandoor. \r\n This is the most popular Indian dish made using tandoor. \r\n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \r\n This Kebab is a very wonderful snack to have. \r\n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \r\n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also.", - Name = "Kathi Kebab", - Price = 3.37m - }, - new - { - Id = 5, - Description = " Chapli Kebabs are a very famous dish of Pakistani cuisine. \r\n This minced meat has a special taste. \r\n The Kebab is made using beef. \r\n This Pakistani dish with an Indian special tadka is all you need to have.", - Name = "Chapli Kebab", - Price = 4.33m - }, - new - { - Id = 6, - Description = " Burrah Kebabs are also known as barrah Kebab. \r\n The Kebab is made up of beef and lots and lots of spices. \r\n This Kebab is very famous Kebab of Mughlai cuisine. \r\n This dish comes under the heavy meal category. \r\n It majorly includes larger pieces of meat. \r\n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish.", - Name = "Burrah Kebab", - Price = 4.36m - }, - new - { - Id = 7, - Description = " This is an Irani dish with an Indian tadka. \r\n This is, in fact, national food of Iran. \r\n The dish is basic but yummy in taste. \r\n They are always served with buttered rice. \r\n Most of the people prefer doogh which is a yogurt drink with this Kebab. \r\n The dish comes under the category of the side dish, but the taste of the dish is very special.", - Name = "Chelow Kebab", - Price = 4.29m - }, - new - { - Id = 8, - Description = " The name of the Kebab is testi Kebab, and here the word testi means jug. \r\n Yes, the Kebab is served in a pot. \r\n You can use dough or foil to cover the pot. \r\n The pot is broken while eating. \r\n We all know how special the taste of “matke ka pani” is. \r\n Similarly, the taste of matka Kebab is very special.", - Name = "Testi Kebab", - Price = 3.69m - }, - new - { - Id = 9, - Description = " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \r\n The dish is very yummy.", - Name = "Dill Salmon Kebab", - Price = 3.99m - }, - new - { - Id = 10, - Description = " Lamb Kebabs are very easy to make. \r\n What all you need to do is marinate the mince meat with all the spices. \r\n You can add egg also just to enhance the taste of Kebab.", - Name = "Lamb Kebab", - Price = 3.79m - }, - new - { - Id = 11, - Description = "A freshly pulled shot of espresso layered with steamed whole milk and thick rich foam to offer a luxurious velvety texture and complex aroma.", - Name = "Cappuccino", - Price = 1.49m - }, - new - { - Id = 12, - Description = "Red Bull is a utility drink to be taken against mental or physical weariness or exhaustion.", - Name = "Red Bull", - Price = 1.87m - }, - new - { - Id = 13, - Description = "Coca-Cola is a carbonated, sweetened soft drink and is the world's best-selling drink. A popular nickname for Coca-Cola is Coke.", - Name = "Coca Cola", - Price = 0.93m - }, - new - { - Id = 14, - Description = "Crisp, refreshing and clean-tasting, Sprite is a lemon and lime-flavoured soft drink.", - Name = "Sprite", - Price = 1.99m - }, - new - { - Id = 15, - Description = "BonAqua is a high-quality drinking water.", - Name = "Bonaqua Sparkling", - Price = 1.24m - }); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.HasOne("KebPOS.Models.Order", "Order") - .WithMany("OrderProducts") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("KebPOS.Models.Product", "Product") - .WithMany("OrderProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Navigation("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Navigation("OrderProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/KebPOS/Migrations/20221127063403_orderModels.cs b/KebPOS/Migrations/20221127063403_orderModels.cs deleted file mode 100644 index 1f2d7bd..0000000 --- a/KebPOS/Migrations/20221127063403_orderModels.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace KebPOS.Migrations -{ - /// - public partial class orderModels : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 1, - column: "OrderDate", - value: new DateTime(2022, 11, 27, 6, 34, 3, 450, DateTimeKind.Utc).AddTicks(638)); - - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 2, - column: "OrderDate", - value: new DateTime(2022, 11, 27, 6, 38, 3, 450, DateTimeKind.Utc).AddTicks(645)); - - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 3, - column: "OrderDate", - value: new DateTime(2022, 11, 27, 6, 43, 3, 450, DateTimeKind.Utc).AddTicks(655)); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 1, - column: "OrderDate", - value: new DateTime(2022, 11, 27, 1, 2, 22, 751, DateTimeKind.Utc).AddTicks(3162)); - - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 2, - column: "OrderDate", - value: new DateTime(2022, 11, 27, 1, 6, 22, 751, DateTimeKind.Utc).AddTicks(3165)); - - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 3, - column: "OrderDate", - value: new DateTime(2022, 11, 27, 1, 11, 22, 751, DateTimeKind.Utc).AddTicks(3172)); - } - } -} diff --git a/KebPOS/Migrations/20230118234647_OrderIdAutoIncrement.Designer.cs b/KebPOS/Migrations/20230118234647_OrderIdAutoIncrement.Designer.cs deleted file mode 100644 index c3fd361..0000000 --- a/KebPOS/Migrations/20230118234647_OrderIdAutoIncrement.Designer.cs +++ /dev/null @@ -1,276 +0,0 @@ -// -using System; -using KebPOS.DbContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace KebPOS.Migrations -{ - [DbContext(typeof(KebabContext))] - [Migration("20230118234647_OrderIdAutoIncrement")] - partial class OrderIdAutoIncrement - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.0"); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("OrderDate") - .HasColumnType("TEXT"); - - b.Property("TotalPrice") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Orders"); - - b.HasData( - new - { - Id = 1, - OrderDate = new DateTime(2023, 1, 18, 23, 46, 47, 836, DateTimeKind.Utc).AddTicks(9114), - TotalPrice = 11.81m - }, - new - { - Id = 2, - OrderDate = new DateTime(2023, 1, 18, 23, 50, 47, 836, DateTimeKind.Utc).AddTicks(9116), - TotalPrice = 6.86m - }, - new - { - Id = 3, - OrderDate = new DateTime(2023, 1, 18, 23, 55, 47, 836, DateTimeKind.Utc).AddTicks(9121), - TotalPrice = 7.75m - }); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.Property("OrderId") - .HasColumnType("INTEGER"); - - b.Property("ProductId") - .HasColumnType("INTEGER"); - - b.HasKey("OrderId", "ProductId"); - - b.HasIndex("ProductId"); - - b.ToTable("OrderProducts"); - - b.HasData( - new - { - OrderId = 1, - ProductId = 1 - }, - new - { - OrderId = 1, - ProductId = 5 - }, - new - { - OrderId = 1, - ProductId = 9 - }, - new - { - OrderId = 2, - ProductId = 1 - }, - new - { - OrderId = 2, - ProductId = 4 - }, - new - { - OrderId = 3, - ProductId = 6 - }, - new - { - OrderId = 3, - ProductId = 3 - }); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Price") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Products"); - - b.HasData( - new - { - Id = 1, - Description = " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \r\n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \r\n You can add other veggies also.", - Name = "Yogurt Kebab", - Price = 3.49m - }, - new - { - Id = 2, - Description = " This Kebab is one among all the most popular and delicious Kebabs. \r\n The special part of this Kebab is that they are grilled on the skewer. \r\n Here the word shish means skewer. And the word Kebab stands for meat. \r\n This dish comes under the category of side dish. \r\n This dish is very famous in Turkey. \r\n Just imagine the taste of Turkish dish with an Indian tadka. \r\n These are most popular of all Kebabs. \r\n Steamed vegetables and salads are served along with these Kebabs.", - Name = "Shish Kebab", - Price = 4.19m - }, - new - { - Id = 3, - Description = "Another name of this Kebab is rotating Kebab. \r\nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \r\nThis comes under the category of popular fast food loved by all. \r\nThe Kebab is made of lamb’s meat. \r\nThe special taste of Kebab is due to its cooking style. \r\nThe Kebabs are cooked slowly so that the meat juice could spread its flavor.", - Name = "Doner Kebab", - Price = 3.39m - }, - new - { - Id = 4, - Description = " Kathi Kebabs are very famous as they are made using tandoor. \r\n This is the most popular Indian dish made using tandoor. \r\n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \r\n This Kebab is a very wonderful snack to have. \r\n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \r\n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also.", - Name = "Kathi Kebab", - Price = 3.37m - }, - new - { - Id = 5, - Description = " Chapli Kebabs are a very famous dish of Pakistani cuisine. \r\n This minced meat has a special taste. \r\n The Kebab is made using beef. \r\n This Pakistani dish with an Indian special tadka is all you need to have.", - Name = "Chapli Kebab", - Price = 4.33m - }, - new - { - Id = 6, - Description = " Burrah Kebabs are also known as barrah Kebab. \r\n The Kebab is made up of beef and lots and lots of spices. \r\n This Kebab is very famous Kebab of Mughlai cuisine. \r\n This dish comes under the heavy meal category. \r\n It majorly includes larger pieces of meat. \r\n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish.", - Name = "Burrah Kebab", - Price = 4.36m - }, - new - { - Id = 7, - Description = " This is an Irani dish with an Indian tadka. \r\n This is, in fact, national food of Iran. \r\n The dish is basic but yummy in taste. \r\n They are always served with buttered rice. \r\n Most of the people prefer doogh which is a yogurt drink with this Kebab. \r\n The dish comes under the category of the side dish, but the taste of the dish is very special.", - Name = "Chelow Kebab", - Price = 4.29m - }, - new - { - Id = 8, - Description = " The name of the Kebab is testi Kebab, and here the word testi means jug. \r\n Yes, the Kebab is served in a pot. \r\n You can use dough or foil to cover the pot. \r\n The pot is broken while eating. \r\n We all know how special the taste of “matke ka pani” is. \r\n Similarly, the taste of matka Kebab is very special.", - Name = "Testi Kebab", - Price = 3.69m - }, - new - { - Id = 9, - Description = " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \r\n The dish is very yummy.", - Name = "Dill Salmon Kebab", - Price = 3.99m - }, - new - { - Id = 10, - Description = " Lamb Kebabs are very easy to make. \r\n What all you need to do is marinate the mince meat with all the spices. \r\n You can add egg also just to enhance the taste of Kebab.", - Name = "Lamb Kebab", - Price = 3.79m - }, - new - { - Id = 11, - Description = "A freshly pulled shot of espresso layered with steamed whole milk and thick rich foam to offer a luxurious velvety texture and complex aroma.", - Name = "Cappuccino", - Price = 1.49m - }, - new - { - Id = 12, - Description = "Red Bull is a utility drink to be taken against mental or physical weariness or exhaustion.", - Name = "Red Bull", - Price = 1.87m - }, - new - { - Id = 13, - Description = "Coca-Cola is a carbonated, sweetened soft drink and is the world's best-selling drink. A popular nickname for Coca-Cola is Coke.", - Name = "Coca Cola", - Price = 0.93m - }, - new - { - Id = 14, - Description = "Crisp, refreshing and clean-tasting, Sprite is a lemon and lime-flavoured soft drink.", - Name = "Sprite", - Price = 1.99m - }, - new - { - Id = 15, - Description = "BonAqua is a high-quality drinking water.", - Name = "Bonaqua Sparkling", - Price = 1.24m - }); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.HasOne("KebPOS.Models.Order", "Order") - .WithMany("OrderProducts") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("KebPOS.Models.Product", "Product") - .WithMany("OrderProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Navigation("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Navigation("OrderProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/KebPOS/Migrations/20230118234647_OrderIdAutoIncrement.cs b/KebPOS/Migrations/20230118234647_OrderIdAutoIncrement.cs deleted file mode 100644 index 55e75f8..0000000 --- a/KebPOS/Migrations/20230118234647_OrderIdAutoIncrement.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace KebPOS.Migrations -{ - /// - public partial class OrderIdAutoIncrement : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 1, - column: "OrderDate", - value: new DateTime(2023, 1, 18, 23, 46, 47, 836, DateTimeKind.Utc).AddTicks(9114)); - - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 2, - column: "OrderDate", - value: new DateTime(2023, 1, 18, 23, 50, 47, 836, DateTimeKind.Utc).AddTicks(9116)); - - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 3, - column: "OrderDate", - value: new DateTime(2023, 1, 18, 23, 55, 47, 836, DateTimeKind.Utc).AddTicks(9121)); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 1, - column: "OrderDate", - value: new DateTime(2022, 11, 27, 6, 34, 3, 450, DateTimeKind.Utc).AddTicks(638)); - - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 2, - column: "OrderDate", - value: new DateTime(2022, 11, 27, 6, 38, 3, 450, DateTimeKind.Utc).AddTicks(645)); - - migrationBuilder.UpdateData( - table: "Orders", - keyColumn: "Id", - keyValue: 3, - column: "OrderDate", - value: new DateTime(2022, 11, 27, 6, 43, 3, 450, DateTimeKind.Utc).AddTicks(655)); - } - } -} diff --git a/KebPOS/Migrations/20230209113426_RemoveOrdersSeeding.Designer.cs b/KebPOS/Migrations/20230209113426_RemoveOrdersSeeding.Designer.cs deleted file mode 100644 index d0f54a0..0000000 --- a/KebPOS/Migrations/20230209113426_RemoveOrdersSeeding.Designer.cs +++ /dev/null @@ -1,219 +0,0 @@ -// -using System; -using KebPOS.DbContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace KebPOS.Migrations -{ - [DbContext(typeof(KebabContext))] - [Migration("20230209113426_RemoveOrdersSeeding")] - partial class RemoveOrdersSeeding - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.0"); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("OrderDate") - .HasColumnType("TEXT"); - - b.Property("TotalPrice") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.Property("OrderId") - .HasColumnType("INTEGER"); - - b.Property("ProductId") - .HasColumnType("INTEGER"); - - b.HasKey("OrderId", "ProductId"); - - b.HasIndex("ProductId"); - - b.ToTable("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Price") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Products"); - - b.HasData( - new - { - Id = 1, - Description = " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \n You can add other veggies also.", - Name = "Yogurt Kebab", - Price = 3.49m - }, - new - { - Id = 2, - Description = " This Kebab is one among all the most popular and delicious Kebabs. \n The special part of this Kebab is that they are grilled on the skewer. \n Here the word shish means skewer. And the word Kebab stands for meat. \n This dish comes under the category of side dish. \n This dish is very famous in Turkey. \n Just imagine the taste of Turkish dish with an Indian tadka. \n These are most popular of all Kebabs. \n Steamed vegetables and salads are served along with these Kebabs.", - Name = "Shish Kebab", - Price = 4.19m - }, - new - { - Id = 3, - Description = "Another name of this Kebab is rotating Kebab. \nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \nThis comes under the category of popular fast food loved by all. \nThe Kebab is made of lamb’s meat. \nThe special taste of Kebab is due to its cooking style. \nThe Kebabs are cooked slowly so that the meat juice could spread its flavor.", - Name = "Doner Kebab", - Price = 3.39m - }, - new - { - Id = 4, - Description = " Kathi Kebabs are very famous as they are made using tandoor. \n This is the most popular Indian dish made using tandoor. \n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \n This Kebab is a very wonderful snack to have. \n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also.", - Name = "Kathi Kebab", - Price = 3.37m - }, - new - { - Id = 5, - Description = " Chapli Kebabs are a very famous dish of Pakistani cuisine. \n This minced meat has a special taste. \n The Kebab is made using beef. \n This Pakistani dish with an Indian special tadka is all you need to have.", - Name = "Chapli Kebab", - Price = 4.33m - }, - new - { - Id = 6, - Description = " Burrah Kebabs are also known as barrah Kebab. \n The Kebab is made up of beef and lots and lots of spices. \n This Kebab is very famous Kebab of Mughlai cuisine. \n This dish comes under the heavy meal category. \n It majorly includes larger pieces of meat. \n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish.", - Name = "Burrah Kebab", - Price = 4.36m - }, - new - { - Id = 7, - Description = " This is an Irani dish with an Indian tadka. \n This is, in fact, national food of Iran. \n The dish is basic but yummy in taste. \n They are always served with buttered rice. \n Most of the people prefer doogh which is a yogurt drink with this Kebab. \n The dish comes under the category of the side dish, but the taste of the dish is very special.", - Name = "Chelow Kebab", - Price = 4.29m - }, - new - { - Id = 8, - Description = " The name of the Kebab is testi Kebab, and here the word testi means jug. \n Yes, the Kebab is served in a pot. \n You can use dough or foil to cover the pot. \n The pot is broken while eating. \n We all know how special the taste of “matke ka pani” is. \n Similarly, the taste of matka Kebab is very special.", - Name = "Testi Kebab", - Price = 3.69m - }, - new - { - Id = 9, - Description = " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \n The dish is very yummy.", - Name = "Dill Salmon Kebab", - Price = 3.99m - }, - new - { - Id = 10, - Description = " Lamb Kebabs are very easy to make. \n What all you need to do is marinate the mince meat with all the spices. \n You can add egg also just to enhance the taste of Kebab.", - Name = "Lamb Kebab", - Price = 3.79m - }, - new - { - Id = 11, - Description = "A freshly pulled shot of espresso layered with steamed whole milk and thick rich foam to offer a luxurious velvety texture and complex aroma.", - Name = "Cappuccino", - Price = 1.49m - }, - new - { - Id = 12, - Description = "Red Bull is a utility drink to be taken against mental or physical weariness or exhaustion.", - Name = "Red Bull", - Price = 1.87m - }, - new - { - Id = 13, - Description = "Coca-Cola is a carbonated, sweetened soft drink and is the world's best-selling drink. A popular nickname for Coca-Cola is Coke.", - Name = "Coca Cola", - Price = 0.93m - }, - new - { - Id = 14, - Description = "Crisp, refreshing and clean-tasting, Sprite is a lemon and lime-flavoured soft drink.", - Name = "Sprite", - Price = 1.99m - }, - new - { - Id = 15, - Description = "BonAqua is a high-quality drinking water.", - Name = "Bonaqua Sparkling", - Price = 1.24m - }); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.HasOne("KebPOS.Models.Order", "Order") - .WithMany("OrderProducts") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("KebPOS.Models.Product", "Product") - .WithMany("OrderProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Navigation("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Navigation("OrderProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/KebPOS/Migrations/20230209113426_RemoveOrdersSeeding.cs b/KebPOS/Migrations/20230209113426_RemoveOrdersSeeding.cs deleted file mode 100644 index 4cdd849..0000000 --- a/KebPOS/Migrations/20230209113426_RemoveOrdersSeeding.cs +++ /dev/null @@ -1,234 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace KebPOS.Migrations -{ - /// - public partial class RemoveOrdersSeeding : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - table: "OrderProducts", - keyColumns: new[] { "OrderId", "ProductId" }, - keyValues: new object[] { 1, 1 }); - - migrationBuilder.DeleteData( - table: "OrderProducts", - keyColumns: new[] { "OrderId", "ProductId" }, - keyValues: new object[] { 1, 5 }); - - migrationBuilder.DeleteData( - table: "OrderProducts", - keyColumns: new[] { "OrderId", "ProductId" }, - keyValues: new object[] { 1, 9 }); - - migrationBuilder.DeleteData( - table: "OrderProducts", - keyColumns: new[] { "OrderId", "ProductId" }, - keyValues: new object[] { 2, 1 }); - - migrationBuilder.DeleteData( - table: "OrderProducts", - keyColumns: new[] { "OrderId", "ProductId" }, - keyValues: new object[] { 2, 4 }); - - migrationBuilder.DeleteData( - table: "OrderProducts", - keyColumns: new[] { "OrderId", "ProductId" }, - keyValues: new object[] { 3, 3 }); - - migrationBuilder.DeleteData( - table: "OrderProducts", - keyColumns: new[] { "OrderId", "ProductId" }, - keyValues: new object[] { 3, 6 }); - - migrationBuilder.DeleteData( - table: "Orders", - keyColumn: "Id", - keyValue: 1); - - migrationBuilder.DeleteData( - table: "Orders", - keyColumn: "Id", - keyValue: 2); - - migrationBuilder.DeleteData( - table: "Orders", - keyColumn: "Id", - keyValue: 3); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 1, - column: "Description", - value: " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \n You can add other veggies also."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 2, - column: "Description", - value: " This Kebab is one among all the most popular and delicious Kebabs. \n The special part of this Kebab is that they are grilled on the skewer. \n Here the word shish means skewer. And the word Kebab stands for meat. \n This dish comes under the category of side dish. \n This dish is very famous in Turkey. \n Just imagine the taste of Turkish dish with an Indian tadka. \n These are most popular of all Kebabs. \n Steamed vegetables and salads are served along with these Kebabs."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 3, - column: "Description", - value: "Another name of this Kebab is rotating Kebab. \nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \nThis comes under the category of popular fast food loved by all. \nThe Kebab is made of lamb’s meat. \nThe special taste of Kebab is due to its cooking style. \nThe Kebabs are cooked slowly so that the meat juice could spread its flavor."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 4, - column: "Description", - value: " Kathi Kebabs are very famous as they are made using tandoor. \n This is the most popular Indian dish made using tandoor. \n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \n This Kebab is a very wonderful snack to have. \n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 5, - column: "Description", - value: " Chapli Kebabs are a very famous dish of Pakistani cuisine. \n This minced meat has a special taste. \n The Kebab is made using beef. \n This Pakistani dish with an Indian special tadka is all you need to have."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 6, - column: "Description", - value: " Burrah Kebabs are also known as barrah Kebab. \n The Kebab is made up of beef and lots and lots of spices. \n This Kebab is very famous Kebab of Mughlai cuisine. \n This dish comes under the heavy meal category. \n It majorly includes larger pieces of meat. \n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 7, - column: "Description", - value: " This is an Irani dish with an Indian tadka. \n This is, in fact, national food of Iran. \n The dish is basic but yummy in taste. \n They are always served with buttered rice. \n Most of the people prefer doogh which is a yogurt drink with this Kebab. \n The dish comes under the category of the side dish, but the taste of the dish is very special."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 8, - column: "Description", - value: " The name of the Kebab is testi Kebab, and here the word testi means jug. \n Yes, the Kebab is served in a pot. \n You can use dough or foil to cover the pot. \n The pot is broken while eating. \n We all know how special the taste of “matke ka pani” is. \n Similarly, the taste of matka Kebab is very special."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 9, - column: "Description", - value: " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \n The dish is very yummy."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 10, - column: "Description", - value: " Lamb Kebabs are very easy to make. \n What all you need to do is marinate the mince meat with all the spices. \n You can add egg also just to enhance the taste of Kebab."); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.InsertData( - table: "Orders", - columns: new[] { "Id", "OrderDate", "TotalPrice" }, - values: new object[,] - { - { 1, new DateTime(2022, 11, 27, 6, 34, 3, 450, DateTimeKind.Utc).AddTicks(638), 11.81m }, - { 2, new DateTime(2022, 11, 27, 6, 38, 3, 450, DateTimeKind.Utc).AddTicks(645), 6.86m }, - { 3, new DateTime(2022, 11, 27, 6, 43, 3, 450, DateTimeKind.Utc).AddTicks(655), 7.75m } - }); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 1, - column: "Description", - value: " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \r\n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \r\n You can add other veggies also."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 2, - column: "Description", - value: " This Kebab is one among all the most popular and delicious Kebabs. \r\n The special part of this Kebab is that they are grilled on the skewer. \r\n Here the word shish means skewer. And the word Kebab stands for meat. \r\n This dish comes under the category of side dish. \r\n This dish is very famous in Turkey. \r\n Just imagine the taste of Turkish dish with an Indian tadka. \r\n These are most popular of all Kebabs. \r\n Steamed vegetables and salads are served along with these Kebabs."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 3, - column: "Description", - value: "Another name of this Kebab is rotating Kebab. \r\nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \r\nThis comes under the category of popular fast food loved by all. \r\nThe Kebab is made of lamb’s meat. \r\nThe special taste of Kebab is due to its cooking style. \r\nThe Kebabs are cooked slowly so that the meat juice could spread its flavor."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 4, - column: "Description", - value: " Kathi Kebabs are very famous as they are made using tandoor. \r\n This is the most popular Indian dish made using tandoor. \r\n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \r\n This Kebab is a very wonderful snack to have. \r\n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \r\n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 5, - column: "Description", - value: " Chapli Kebabs are a very famous dish of Pakistani cuisine. \r\n This minced meat has a special taste. \r\n The Kebab is made using beef. \r\n This Pakistani dish with an Indian special tadka is all you need to have."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 6, - column: "Description", - value: " Burrah Kebabs are also known as barrah Kebab. \r\n The Kebab is made up of beef and lots and lots of spices. \r\n This Kebab is very famous Kebab of Mughlai cuisine. \r\n This dish comes under the heavy meal category. \r\n It majorly includes larger pieces of meat. \r\n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 7, - column: "Description", - value: " This is an Irani dish with an Indian tadka. \r\n This is, in fact, national food of Iran. \r\n The dish is basic but yummy in taste. \r\n They are always served with buttered rice. \r\n Most of the people prefer doogh which is a yogurt drink with this Kebab. \r\n The dish comes under the category of the side dish, but the taste of the dish is very special."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 8, - column: "Description", - value: " The name of the Kebab is testi Kebab, and here the word testi means jug. \r\n Yes, the Kebab is served in a pot. \r\n You can use dough or foil to cover the pot. \r\n The pot is broken while eating. \r\n We all know how special the taste of “matke ka pani” is. \r\n Similarly, the taste of matka Kebab is very special."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 9, - column: "Description", - value: " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \r\n The dish is very yummy."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 10, - column: "Description", - value: " Lamb Kebabs are very easy to make. \r\n What all you need to do is marinate the mince meat with all the spices. \r\n You can add egg also just to enhance the taste of Kebab."); - - migrationBuilder.InsertData( - table: "OrderProducts", - columns: new[] { "OrderId", "ProductId" }, - values: new object[,] - { - { 1, 1 }, - { 1, 5 }, - { 1, 9 }, - { 2, 1 }, - { 2, 4 }, - { 3, 3 }, - { 3, 6 } - }); - } - } -} diff --git a/KebPOS/Migrations/20230303013924_quantity.Designer.cs b/KebPOS/Migrations/20230303013924_quantity.Designer.cs deleted file mode 100644 index 32230c4..0000000 --- a/KebPOS/Migrations/20230303013924_quantity.Designer.cs +++ /dev/null @@ -1,222 +0,0 @@ -// -using System; -using KebPOS.DbContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace KebPOS.Migrations -{ - [DbContext(typeof(KebabContext))] - [Migration("20230303013924_quantity")] - partial class quantity - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.0"); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("OrderDate") - .HasColumnType("TEXT"); - - b.Property("TotalPrice") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.Property("OrderId") - .HasColumnType("INTEGER"); - - b.Property("ProductId") - .HasColumnType("INTEGER"); - - b.Property("Quantity") - .HasColumnType("INTEGER"); - - b.HasKey("OrderId", "ProductId"); - - b.HasIndex("ProductId"); - - b.ToTable("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Price") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Products"); - - b.HasData( - new - { - Id = 1, - Description = " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \r\n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \r\n You can add other veggies also.", - Name = "Yogurt Kebab", - Price = 3.49m - }, - new - { - Id = 2, - Description = " This Kebab is one among all the most popular and delicious Kebabs. \r\n The special part of this Kebab is that they are grilled on the skewer. \r\n Here the word shish means skewer. And the word Kebab stands for meat. \r\n This dish comes under the category of side dish. \r\n This dish is very famous in Turkey. \r\n Just imagine the taste of Turkish dish with an Indian tadka. \r\n These are most popular of all Kebabs. \r\n Steamed vegetables and salads are served along with these Kebabs.", - Name = "Shish Kebab", - Price = 4.19m - }, - new - { - Id = 3, - Description = "Another name of this Kebab is rotating Kebab. \r\nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \r\nThis comes under the category of popular fast food loved by all. \r\nThe Kebab is made of lamb’s meat. \r\nThe special taste of Kebab is due to its cooking style. \r\nThe Kebabs are cooked slowly so that the meat juice could spread its flavor.", - Name = "Doner Kebab", - Price = 3.39m - }, - new - { - Id = 4, - Description = " Kathi Kebabs are very famous as they are made using tandoor. \r\n This is the most popular Indian dish made using tandoor. \r\n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \r\n This Kebab is a very wonderful snack to have. \r\n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \r\n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also.", - Name = "Kathi Kebab", - Price = 3.37m - }, - new - { - Id = 5, - Description = " Chapli Kebabs are a very famous dish of Pakistani cuisine. \r\n This minced meat has a special taste. \r\n The Kebab is made using beef. \r\n This Pakistani dish with an Indian special tadka is all you need to have.", - Name = "Chapli Kebab", - Price = 4.33m - }, - new - { - Id = 6, - Description = " Burrah Kebabs are also known as barrah Kebab. \r\n The Kebab is made up of beef and lots and lots of spices. \r\n This Kebab is very famous Kebab of Mughlai cuisine. \r\n This dish comes under the heavy meal category. \r\n It majorly includes larger pieces of meat. \r\n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish.", - Name = "Burrah Kebab", - Price = 4.36m - }, - new - { - Id = 7, - Description = " This is an Irani dish with an Indian tadka. \r\n This is, in fact, national food of Iran. \r\n The dish is basic but yummy in taste. \r\n They are always served with buttered rice. \r\n Most of the people prefer doogh which is a yogurt drink with this Kebab. \r\n The dish comes under the category of the side dish, but the taste of the dish is very special.", - Name = "Chelow Kebab", - Price = 4.29m - }, - new - { - Id = 8, - Description = " The name of the Kebab is testi Kebab, and here the word testi means jug. \r\n Yes, the Kebab is served in a pot. \r\n You can use dough or foil to cover the pot. \r\n The pot is broken while eating. \r\n We all know how special the taste of “matke ka pani” is. \r\n Similarly, the taste of matka Kebab is very special.", - Name = "Testi Kebab", - Price = 3.69m - }, - new - { - Id = 9, - Description = " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \r\n The dish is very yummy.", - Name = "Dill Salmon Kebab", - Price = 3.99m - }, - new - { - Id = 10, - Description = " Lamb Kebabs are very easy to make. \r\n What all you need to do is marinate the mince meat with all the spices. \r\n You can add egg also just to enhance the taste of Kebab.", - Name = "Lamb Kebab", - Price = 3.79m - }, - new - { - Id = 11, - Description = "A freshly pulled shot of espresso layered with steamed whole milk and thick rich foam to offer a luxurious velvety texture and complex aroma.", - Name = "Cappuccino", - Price = 1.49m - }, - new - { - Id = 12, - Description = "Red Bull is a utility drink to be taken against mental or physical weariness or exhaustion.", - Name = "Red Bull", - Price = 1.87m - }, - new - { - Id = 13, - Description = "Coca-Cola is a carbonated, sweetened soft drink and is the world's best-selling drink. A popular nickname for Coca-Cola is Coke.", - Name = "Coca Cola", - Price = 0.93m - }, - new - { - Id = 14, - Description = "Crisp, refreshing and clean-tasting, Sprite is a lemon and lime-flavoured soft drink.", - Name = "Sprite", - Price = 1.99m - }, - new - { - Id = 15, - Description = "BonAqua is a high-quality drinking water.", - Name = "Bonaqua Sparkling", - Price = 1.24m - }); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.HasOne("KebPOS.Models.Order", "Order") - .WithMany("OrderProducts") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("KebPOS.Models.Product", "Product") - .WithMany("OrderProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Navigation("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Navigation("OrderProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/KebPOS/Migrations/20230303013924_quantity.cs b/KebPOS/Migrations/20230303013924_quantity.cs deleted file mode 100644 index 18508b9..0000000 --- a/KebPOS/Migrations/20230303013924_quantity.cs +++ /dev/null @@ -1,169 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace KebPOS.Migrations -{ - /// - public partial class quantity : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Quantity", - table: "OrderProducts", - type: "INTEGER", - nullable: false, - defaultValue: 0); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 1, - column: "Description", - value: " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \r\n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \r\n You can add other veggies also."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 2, - column: "Description", - value: " This Kebab is one among all the most popular and delicious Kebabs. \r\n The special part of this Kebab is that they are grilled on the skewer. \r\n Here the word shish means skewer. And the word Kebab stands for meat. \r\n This dish comes under the category of side dish. \r\n This dish is very famous in Turkey. \r\n Just imagine the taste of Turkish dish with an Indian tadka. \r\n These are most popular of all Kebabs. \r\n Steamed vegetables and salads are served along with these Kebabs."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 3, - column: "Description", - value: "Another name of this Kebab is rotating Kebab. \r\nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \r\nThis comes under the category of popular fast food loved by all. \r\nThe Kebab is made of lamb’s meat. \r\nThe special taste of Kebab is due to its cooking style. \r\nThe Kebabs are cooked slowly so that the meat juice could spread its flavor."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 4, - column: "Description", - value: " Kathi Kebabs are very famous as they are made using tandoor. \r\n This is the most popular Indian dish made using tandoor. \r\n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \r\n This Kebab is a very wonderful snack to have. \r\n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \r\n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 5, - column: "Description", - value: " Chapli Kebabs are a very famous dish of Pakistani cuisine. \r\n This minced meat has a special taste. \r\n The Kebab is made using beef. \r\n This Pakistani dish with an Indian special tadka is all you need to have."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 6, - column: "Description", - value: " Burrah Kebabs are also known as barrah Kebab. \r\n The Kebab is made up of beef and lots and lots of spices. \r\n This Kebab is very famous Kebab of Mughlai cuisine. \r\n This dish comes under the heavy meal category. \r\n It majorly includes larger pieces of meat. \r\n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 7, - column: "Description", - value: " This is an Irani dish with an Indian tadka. \r\n This is, in fact, national food of Iran. \r\n The dish is basic but yummy in taste. \r\n They are always served with buttered rice. \r\n Most of the people prefer doogh which is a yogurt drink with this Kebab. \r\n The dish comes under the category of the side dish, but the taste of the dish is very special."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 8, - column: "Description", - value: " The name of the Kebab is testi Kebab, and here the word testi means jug. \r\n Yes, the Kebab is served in a pot. \r\n You can use dough or foil to cover the pot. \r\n The pot is broken while eating. \r\n We all know how special the taste of “matke ka pani” is. \r\n Similarly, the taste of matka Kebab is very special."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 9, - column: "Description", - value: " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \r\n The dish is very yummy."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 10, - column: "Description", - value: " Lamb Kebabs are very easy to make. \r\n What all you need to do is marinate the mince meat with all the spices. \r\n You can add egg also just to enhance the taste of Kebab."); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Quantity", - table: "OrderProducts"); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 1, - column: "Description", - value: " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \n You can add other veggies also."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 2, - column: "Description", - value: " This Kebab is one among all the most popular and delicious Kebabs. \n The special part of this Kebab is that they are grilled on the skewer. \n Here the word shish means skewer. And the word Kebab stands for meat. \n This dish comes under the category of side dish. \n This dish is very famous in Turkey. \n Just imagine the taste of Turkish dish with an Indian tadka. \n These are most popular of all Kebabs. \n Steamed vegetables and salads are served along with these Kebabs."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 3, - column: "Description", - value: "Another name of this Kebab is rotating Kebab. \nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \nThis comes under the category of popular fast food loved by all. \nThe Kebab is made of lamb’s meat. \nThe special taste of Kebab is due to its cooking style. \nThe Kebabs are cooked slowly so that the meat juice could spread its flavor."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 4, - column: "Description", - value: " Kathi Kebabs are very famous as they are made using tandoor. \n This is the most popular Indian dish made using tandoor. \n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \n This Kebab is a very wonderful snack to have. \n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 5, - column: "Description", - value: " Chapli Kebabs are a very famous dish of Pakistani cuisine. \n This minced meat has a special taste. \n The Kebab is made using beef. \n This Pakistani dish with an Indian special tadka is all you need to have."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 6, - column: "Description", - value: " Burrah Kebabs are also known as barrah Kebab. \n The Kebab is made up of beef and lots and lots of spices. \n This Kebab is very famous Kebab of Mughlai cuisine. \n This dish comes under the heavy meal category. \n It majorly includes larger pieces of meat. \n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 7, - column: "Description", - value: " This is an Irani dish with an Indian tadka. \n This is, in fact, national food of Iran. \n The dish is basic but yummy in taste. \n They are always served with buttered rice. \n Most of the people prefer doogh which is a yogurt drink with this Kebab. \n The dish comes under the category of the side dish, but the taste of the dish is very special."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 8, - column: "Description", - value: " The name of the Kebab is testi Kebab, and here the word testi means jug. \n Yes, the Kebab is served in a pot. \n You can use dough or foil to cover the pot. \n The pot is broken while eating. \n We all know how special the taste of “matke ka pani” is. \n Similarly, the taste of matka Kebab is very special."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 9, - column: "Description", - value: " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \n The dish is very yummy."); - - migrationBuilder.UpdateData( - table: "Products", - keyColumn: "Id", - keyValue: 10, - column: "Description", - value: " Lamb Kebabs are very easy to make. \n What all you need to do is marinate the mince meat with all the spices. \n You can add egg also just to enhance the taste of Kebab."); - } - } -} diff --git a/KebPOS/Migrations/20240112084734_InitialCreate.Designer.cs b/KebPOS/Migrations/20240112084734_InitialCreate.Designer.cs deleted file mode 100644 index 1e8da45..0000000 --- a/KebPOS/Migrations/20240112084734_InitialCreate.Designer.cs +++ /dev/null @@ -1,222 +0,0 @@ -// -using System; -using KebPOS.DbContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace KebPOS.Migrations -{ - [DbContext(typeof(KebabContext))] - [Migration("20240112084734_InitialCreate")] - partial class InitialCreate - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.0"); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("OrderDate") - .HasColumnType("TEXT"); - - b.Property("TotalPrice") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.Property("OrderId") - .HasColumnType("INTEGER"); - - b.Property("ProductId") - .HasColumnType("INTEGER"); - - b.Property("Quantity") - .HasColumnType("INTEGER"); - - b.HasKey("OrderId", "ProductId"); - - b.HasIndex("ProductId"); - - b.ToTable("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Price") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Products"); - - b.HasData( - new - { - Id = 1, - Description = " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \r\n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \r\n You can add other veggies also.", - Name = "Yogurt Kebab", - Price = 3.49m - }, - new - { - Id = 2, - Description = " This Kebab is one among all the most popular and delicious Kebabs. \r\n The special part of this Kebab is that they are grilled on the skewer. \r\n Here the word shish means skewer. And the word Kebab stands for meat. \r\n This dish comes under the category of side dish. \r\n This dish is very famous in Turkey. \r\n Just imagine the taste of Turkish dish with an Indian tadka. \r\n These are most popular of all Kebabs. \r\n Steamed vegetables and salads are served along with these Kebabs.", - Name = "Shish Kebab", - Price = 4.19m - }, - new - { - Id = 3, - Description = "Another name of this Kebab is rotating Kebab. \r\nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \r\nThis comes under the category of popular fast food loved by all. \r\nThe Kebab is made of lamb’s meat. \r\nThe special taste of Kebab is due to its cooking style. \r\nThe Kebabs are cooked slowly so that the meat juice could spread its flavor.", - Name = "Doner Kebab", - Price = 3.39m - }, - new - { - Id = 4, - Description = " Kathi Kebabs are very famous as they are made using tandoor. \r\n This is the most popular Indian dish made using tandoor. \r\n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \r\n This Kebab is a very wonderful snack to have. \r\n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \r\n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also.", - Name = "Kathi Kebab", - Price = 3.37m - }, - new - { - Id = 5, - Description = " Chapli Kebabs are a very famous dish of Pakistani cuisine. \r\n This minced meat has a special taste. \r\n The Kebab is made using beef. \r\n This Pakistani dish with an Indian special tadka is all you need to have.", - Name = "Chapli Kebab", - Price = 4.33m - }, - new - { - Id = 6, - Description = " Burrah Kebabs are also known as barrah Kebab. \r\n The Kebab is made up of beef and lots and lots of spices. \r\n This Kebab is very famous Kebab of Mughlai cuisine. \r\n This dish comes under the heavy meal category. \r\n It majorly includes larger pieces of meat. \r\n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish.", - Name = "Burrah Kebab", - Price = 4.36m - }, - new - { - Id = 7, - Description = " This is an Irani dish with an Indian tadka. \r\n This is, in fact, national food of Iran. \r\n The dish is basic but yummy in taste. \r\n They are always served with buttered rice. \r\n Most of the people prefer doogh which is a yogurt drink with this Kebab. \r\n The dish comes under the category of the side dish, but the taste of the dish is very special.", - Name = "Chelow Kebab", - Price = 4.29m - }, - new - { - Id = 8, - Description = " The name of the Kebab is testi Kebab, and here the word testi means jug. \r\n Yes, the Kebab is served in a pot. \r\n You can use dough or foil to cover the pot. \r\n The pot is broken while eating. \r\n We all know how special the taste of “matke ka pani” is. \r\n Similarly, the taste of matka Kebab is very special.", - Name = "Testi Kebab", - Price = 3.69m - }, - new - { - Id = 9, - Description = " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \r\n The dish is very yummy.", - Name = "Dill Salmon Kebab", - Price = 3.99m - }, - new - { - Id = 10, - Description = " Lamb Kebabs are very easy to make. \r\n What all you need to do is marinate the mince meat with all the spices. \r\n You can add egg also just to enhance the taste of Kebab.", - Name = "Lamb Kebab", - Price = 3.79m - }, - new - { - Id = 11, - Description = "A freshly pulled shot of espresso layered with steamed whole milk and thick rich foam to offer a luxurious velvety texture and complex aroma.", - Name = "Cappuccino", - Price = 1.49m - }, - new - { - Id = 12, - Description = "Red Bull is a utility drink to be taken against mental or physical weariness or exhaustion.", - Name = "Red Bull", - Price = 1.87m - }, - new - { - Id = 13, - Description = "Coca-Cola is a carbonated, sweetened soft drink and is the world's best-selling drink. A popular nickname for Coca-Cola is Coke.", - Name = "Coca Cola", - Price = 0.93m - }, - new - { - Id = 14, - Description = "Crisp, refreshing and clean-tasting, Sprite is a lemon and lime-flavoured soft drink.", - Name = "Sprite", - Price = 1.99m - }, - new - { - Id = 15, - Description = "BonAqua is a high-quality drinking water.", - Name = "Bonaqua Sparkling", - Price = 1.24m - }); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.HasOne("KebPOS.Models.Order", "Order") - .WithMany("OrderProducts") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("KebPOS.Models.Product", "Product") - .WithMany("OrderProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Navigation("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Navigation("OrderProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/KebPOS/Migrations/KebabContextModelSnapshot.cs b/KebPOS/Migrations/KebabContextModelSnapshot.cs deleted file mode 100644 index addafec..0000000 --- a/KebPOS/Migrations/KebabContextModelSnapshot.cs +++ /dev/null @@ -1,219 +0,0 @@ -// -using System; -using KebPOS.DbContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace KebPOS.Migrations -{ - [DbContext(typeof(KebabContext))] - partial class KebabContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.0"); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("OrderDate") - .HasColumnType("TEXT"); - - b.Property("TotalPrice") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.Property("OrderId") - .HasColumnType("INTEGER"); - - b.Property("ProductId") - .HasColumnType("INTEGER"); - - b.Property("Quantity") - .HasColumnType("INTEGER"); - - b.HasKey("OrderId", "ProductId"); - - b.HasIndex("ProductId"); - - b.ToTable("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Price") - .HasPrecision(18, 2) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Products"); - - b.HasData( - new - { - Id = 1, - Description = " The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. \r\n This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. \r\n You can add other veggies also.", - Name = "Yogurt Kebab", - Price = 3.49m - }, - new - { - Id = 2, - Description = " This Kebab is one among all the most popular and delicious Kebabs. \r\n The special part of this Kebab is that they are grilled on the skewer. \r\n Here the word shish means skewer. And the word Kebab stands for meat. \r\n This dish comes under the category of side dish. \r\n This dish is very famous in Turkey. \r\n Just imagine the taste of Turkish dish with an Indian tadka. \r\n These are most popular of all Kebabs. \r\n Steamed vegetables and salads are served along with these Kebabs.", - Name = "Shish Kebab", - Price = 4.19m - }, - new - { - Id = 3, - Description = "Another name of this Kebab is rotating Kebab. \r\nAnd this wonderful name is given to this Kebab because it is made on a vertical rotating spit. \r\nThis comes under the category of popular fast food loved by all. \r\nThe Kebab is made of lamb’s meat. \r\nThe special taste of Kebab is due to its cooking style. \r\nThe Kebabs are cooked slowly so that the meat juice could spread its flavor.", - Name = "Doner Kebab", - Price = 3.39m - }, - new - { - Id = 4, - Description = " Kathi Kebabs are very famous as they are made using tandoor. \r\n This is the most popular Indian dish made using tandoor. \r\n We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. \r\n This Kebab is a very wonderful snack to have. \r\n The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. \r\n You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also.", - Name = "Kathi Kebab", - Price = 3.37m - }, - new - { - Id = 5, - Description = " Chapli Kebabs are a very famous dish of Pakistani cuisine. \r\n This minced meat has a special taste. \r\n The Kebab is made using beef. \r\n This Pakistani dish with an Indian special tadka is all you need to have.", - Name = "Chapli Kebab", - Price = 4.33m - }, - new - { - Id = 6, - Description = " Burrah Kebabs are also known as barrah Kebab. \r\n The Kebab is made up of beef and lots and lots of spices. \r\n This Kebab is very famous Kebab of Mughlai cuisine. \r\n This dish comes under the heavy meal category. \r\n It majorly includes larger pieces of meat. \r\n If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish.", - Name = "Burrah Kebab", - Price = 4.36m - }, - new - { - Id = 7, - Description = " This is an Irani dish with an Indian tadka. \r\n This is, in fact, national food of Iran. \r\n The dish is basic but yummy in taste. \r\n They are always served with buttered rice. \r\n Most of the people prefer doogh which is a yogurt drink with this Kebab. \r\n The dish comes under the category of the side dish, but the taste of the dish is very special.", - Name = "Chelow Kebab", - Price = 4.29m - }, - new - { - Id = 8, - Description = " The name of the Kebab is testi Kebab, and here the word testi means jug. \r\n Yes, the Kebab is served in a pot. \r\n You can use dough or foil to cover the pot. \r\n The pot is broken while eating. \r\n We all know how special the taste of “matke ka pani” is. \r\n Similarly, the taste of matka Kebab is very special.", - Name = "Testi Kebab", - Price = 3.69m - }, - new - { - Id = 9, - Description = " Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. \r\n The dish is very yummy.", - Name = "Dill Salmon Kebab", - Price = 3.99m - }, - new - { - Id = 10, - Description = " Lamb Kebabs are very easy to make. \r\n What all you need to do is marinate the mince meat with all the spices. \r\n You can add egg also just to enhance the taste of Kebab.", - Name = "Lamb Kebab", - Price = 3.79m - }, - new - { - Id = 11, - Description = "A freshly pulled shot of espresso layered with steamed whole milk and thick rich foam to offer a luxurious velvety texture and complex aroma.", - Name = "Cappuccino", - Price = 1.49m - }, - new - { - Id = 12, - Description = "Red Bull is a utility drink to be taken against mental or physical weariness or exhaustion.", - Name = "Red Bull", - Price = 1.87m - }, - new - { - Id = 13, - Description = "Coca-Cola is a carbonated, sweetened soft drink and is the world's best-selling drink. A popular nickname for Coca-Cola is Coke.", - Name = "Coca Cola", - Price = 0.93m - }, - new - { - Id = 14, - Description = "Crisp, refreshing and clean-tasting, Sprite is a lemon and lime-flavoured soft drink.", - Name = "Sprite", - Price = 1.99m - }, - new - { - Id = 15, - Description = "BonAqua is a high-quality drinking water.", - Name = "Bonaqua Sparkling", - Price = 1.24m - }); - }); - - modelBuilder.Entity("KebPOS.Models.OrderProduct", b => - { - b.HasOne("KebPOS.Models.Order", "Order") - .WithMany("OrderProducts") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("KebPOS.Models.Product", "Product") - .WithMany("OrderProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("KebPOS.Models.Order", b => - { - b.Navigation("OrderProducts"); - }); - - modelBuilder.Entity("KebPOS.Models.Product", b => - { - b.Navigation("OrderProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/KebPOS/Models/Dtos/ProductDto.cs b/KebPOS/Models/Dtos/ProductDto.cs deleted file mode 100644 index 2f63a61..0000000 --- a/KebPOS/Models/Dtos/ProductDto.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace KebPOS.Models.Dtos; - -public class ProductDto -{ - public int Id { get; set; } - public string Name { get; set; } - public decimal Price { get; set; } -} diff --git a/KebPOS/Models/Enums.cs b/KebPOS/Models/Enums.cs deleted file mode 100644 index 21114b8..0000000 --- a/KebPOS/Models/Enums.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace KebPOS.Models; - -internal static class Enums -{ - public enum MainMenuSelections - { - NewOrder, - ViewOrders, - ViewOrderDetails, - DeleteOrder, - ManageProducts, - CloseApplication, - ViewReports - } - - public enum ManageProductsSelections - { - ViewProducts, - ViewProductDetails, - AddProduct, - UpdateProduct, - DeleteProduct, - ReturnToMainMenu - } - - public enum ViewReportsSelections - { - SalesPerMonth, - SalesPerYear, - SalesPerDay, - SalesPerWeek, - ReturnToMainMenu - } - - public enum ProductProperties - { - Id, - Name, - Description, - Price, - MainMenu - } -} diff --git a/KebPOS/Models/Order.cs b/KebPOS/Models/Order.cs deleted file mode 100644 index 2b50838..0000000 --- a/KebPOS/Models/Order.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace KebPOS.Models; - -public class Order -{ - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int Id { get; set; } - public DateTime OrderDate { get; set; } - - [Precision(18, 2)] - public decimal TotalPrice { get; set; } - public ICollection OrderProducts { get; set; } -} diff --git a/KebPOS/Models/OrderProduct.cs b/KebPOS/Models/OrderProduct.cs deleted file mode 100644 index 4a0988b..0000000 --- a/KebPOS/Models/OrderProduct.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace KebPOS.Models; - -public class OrderProduct -{ - public int OrderId { get; set; } - public Order Order { get; set; } - - public int ProductId { get; set; } - public Product Product { get; set; } - - public int Quantity { get; set; } -} diff --git a/KebPOS/Models/Product.cs b/KebPOS/Models/Product.cs deleted file mode 100644 index 811283d..0000000 --- a/KebPOS/Models/Product.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System.ComponentModel.DataAnnotations; - -namespace KebPOS.Models; - -public class Product -{ - [Key] - public int Id { get; set; } - - [Required] - [MaxLength(100)] - public string Name { get; set; } - - [MaxLength(200)] - public string Description { get; set; } - - [Precision(18, 2)] - public decimal Price { get; set; } - - public ICollection OrderProducts { get; set; } -} diff --git a/KebPOS/Program.cs b/KebPOS/Program.cs deleted file mode 100644 index 087a1be..0000000 --- a/KebPOS/Program.cs +++ /dev/null @@ -1,6 +0,0 @@ -using KebPOS; - -Console.Clear(); - -UserInterface _userinterface = new(); -_userinterface.InitializeMenu(); \ No newline at end of file diff --git a/KebPOS/Properties/launchSettings.json b/KebPOS/Properties/launchSettings.json deleted file mode 100644 index b4c3eeb..0000000 --- a/KebPOS/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "KebPOS": { - "commandName": "Project", - "workingDirectory": "C:\\Users\\sipah\\Desktop\\serdar\\projeler\\pointofsle\\CONSOLE.PointOfSale\\KebPOS" - } - } -} \ No newline at end of file diff --git a/KebPOS/Services/ProductService.cs b/KebPOS/Services/ProductService.cs deleted file mode 100644 index c95dd12..0000000 --- a/KebPOS/Services/ProductService.cs +++ /dev/null @@ -1,284 +0,0 @@ -using KebPOS.DbContexts; -using KebPOS.Models; -using Spectre.Console; - -namespace KebPOS.Services; - -public class ProductService -{ - internal static void InsertProduct() - { - bool exit = false; - bool addNewProduct = true; - - while (addNewProduct) - { - bool isDuplicate = true; - bool nameValid = false; - bool pricePos = false; - bool priceValid = false; - bool descriptionValid = false; - int nameLenghtLimit = 20; - int descriptionLengthLimit = 200; - var product = new Product(); - product = new Product(); - - - while (!nameValid || isDuplicate) - { - Console.Clear(); - product.Name = AnsiConsole.Ask("Product's name (20 char limit):"); - - nameValid = Validation.CheckStringLength(product.Name, nameLenghtLimit); - isDuplicate = Validation.CheckDuplicateProductName(product); - - if (!nameValid) - { - Console.WriteLine($"The product name {product.Name} is over 20 characters."); - } - if (isDuplicate) - { - Console.WriteLine($"There is already a product named {product.Name}."); - } - if (!nameValid || isDuplicate) - { - Console.WriteLine("Press any key to continue. Or press b to go back"); - ConsoleKeyInfo keyInfo = Console.ReadKey(); - if (keyInfo.KeyChar.ToString().ToLower() == "b") - { - // Perform some action when 'b' is pressed - exit = true; - nameValid = true; - isDuplicate = false; - } - } - } - if (exit) - { - addNewProduct = false; - } - else - { - - while (!pricePos || !priceValid) - { - Console.Clear(); - product.Price = AnsiConsole.Ask("Product's price:"); - - pricePos = Validation.CheckPrice(product.Price); - priceValid = Validation.CheckValid(product.Price); - - - if (!pricePos) - { - Console.WriteLine("Price can not be negative."); - } - if (!priceValid) - { - Console.WriteLine($"{product.Price} is not a valid entry"); - } - if (!priceValid || !priceValid) - { - Console.WriteLine("Press any key to continue."); - Console.ReadKey(); - } - - } - while (!descriptionValid) - { - Console.Clear(); - product.Description = AnsiConsole.Ask("Product's description (200 char limit):"); - descriptionValid = Validation.CheckStringLength(product.Description, descriptionLengthLimit); - if (!descriptionValid) - { - Console.WriteLine("The product description is over 200 characters"); - Console.ReadKey(); - } - } - - KebabController.AddProduct(product); - addNewProduct = AnsiConsole.Confirm("Would you like to enter a new product?"); - } - } - } - - public static List GetProductsFromDatabase() - { - using var db = new KebabContext(); - var products = db.Products - .ToList(); - return products; - } - public static List GetProducts() - { - var products = new List() - { - new Product() - { - Id = 1, - Name = "Yogurt Kebab", - Description = """ - The other name of this yummy Kebab is “good for you Kebab” the Kebab is made up of paneer, raisins, oats and creamy yogurt. - This Kebab is a total combination of health and taste. The addition of extraordinary paneer simply enhances the taste of the Kebab. - You can add other veggies also. - """, - Price = 3.49m - }, - new Product() - { - Id = 2, - Name = "Shish Kebab", - Description = """ - This Kebab is one among all the most popular and delicious Kebabs. - The special part of this Kebab is that they are grilled on the skewer. - Here the word shish means skewer. And the word Kebab stands for meat. - This dish comes under the category of side dish. - This dish is very famous in Turkey. - Just imagine the taste of Turkish dish with an Indian tadka. - These are most popular of all Kebabs. - Steamed vegetables and salads are served along with these Kebabs. - """, - Price = 4.19m - }, - new Product() - { - Id = 3, - Name = "Doner Kebab", - Description = """ - Another name of this Kebab is rotating Kebab. - And this wonderful name is given to this Kebab because it is made on a vertical rotating spit. - This comes under the category of popular fast food loved by all. - The Kebab is made of lamb’s meat. - The special taste of Kebab is due to its cooking style. - The Kebabs are cooked slowly so that the meat juice could spread its flavor. - """, - Price = 3.39m - }, - new Product() - { - Id = 4, - Name = "Kathi Kebab", - Description = """ - Kathi Kebabs are very famous as they are made using tandoor. - This is the most popular Indian dish made using tandoor. - We all know the taste of tandoori chicken and the reason behind its scrumptious taste is tandoor. - This Kebab is a very wonderful snack to have. - The best way of having these yummy Kathi Kebabs is by rolling them in Kathi roll. - You can add lots and lots of chutney on the roll so that the taste of Kebabs enhances your mood also. - """, - Price = 3.37m - }, - new Product() - { - Id = 5, - Name = "Chapli Kebab", - Description = """ - Chapli Kebabs are a very famous dish of Pakistani cuisine. - This minced meat has a special taste. - The Kebab is made using beef. - This Pakistani dish with an Indian special tadka is all you need to have. - """, - Price = 4.33m - }, - new Product() - { - Id = 6, - Name = "Burrah Kebab", - Description = """ - Burrah Kebabs are also known as barrah Kebab. - The Kebab is made up of beef and lots and lots of spices. - This Kebab is very famous Kebab of Mughlai cuisine. - This dish comes under the heavy meal category. - It majorly includes larger pieces of meat. - If you are also among the Mughlai cuisine lovers, then you can’t afford to miss such an amazing dish. - """, - Price = 4.36m - }, - new Product() - { - Id = 7, - Name = "Chelow Kebab", - Description = """ - This is an Irani dish with an Indian tadka. - This is, in fact, national food of Iran. - The dish is basic but yummy in taste. - They are always served with buttered rice. - Most of the people prefer doogh which is a yogurt drink with this Kebab. - The dish comes under the category of the side dish, but the taste of the dish is very special. - """, - Price = 4.29m - }, - new Product() - { - Id = 8, - Name = "Testi Kebab", - Description = """ - The name of the Kebab is testi Kebab, and here the word testi means jug. - Yes, the Kebab is served in a pot. - You can use dough or foil to cover the pot. - The pot is broken while eating. - We all know how special the taste of “matke ka pani” is. - Similarly, the taste of matka Kebab is very special. - """, - Price = 3.69m - }, - new Product() - { - Id = 9, - Name = "Dill Salmon Kebab", - Description = """ - Dill salmon Kebab is very special Kebab for all seafood lovers and especially for fish lovers. - The dish is very yummy. - """, - Price = 3.99m - }, - new Product() - { - Id = 10, - Name = "Lamb Kebab", - Description = """ - Lamb Kebabs are very easy to make. - What all you need to do is marinate the mince meat with all the spices. - You can add egg also just to enhance the taste of Kebab. - """, - Price = 3.79m - }, - new Product() - { - Id = 11, - Name = "Cappuccino", - Description = "A freshly pulled shot of espresso layered with steamed whole milk and thick rich foam to offer a luxurious velvety texture and complex aroma.", - Price = 1.49m - }, - new Product() - { - Id = 12, - Name = "Red Bull", - Description = "Red Bull is a utility drink to be taken against mental or physical weariness or exhaustion.", - Price = 1.87m - }, - new Product() - { - Id = 13, - Name = "Coca Cola", - Description = "Coca-Cola is a carbonated, sweetened soft drink and is the world's best-selling drink. A popular nickname for Coca-Cola is Coke.", - Price = 0.93m - }, - new Product() - { - Id = 14, - Name = "Sprite", - Description = "Crisp, refreshing and clean-tasting, Sprite is a lemon and lime-flavoured soft drink.", - Price = 1.99m - }, - new Product() - { - Id = 15, - Name = "Bonaqua Sparkling", - Description = "BonAqua is a high-quality drinking water.", - Price = 1.24m - } - }; - return products; - } -} diff --git a/KebPOS/Services/ReportsService.cs b/KebPOS/Services/ReportsService.cs deleted file mode 100644 index c4ecdcb..0000000 --- a/KebPOS/Services/ReportsService.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace KebPOS.Services; - -internal class ReportsService -{ - public static void GetSalesPerMonth() - { - // TODO - } - - public static void GetSalesPerYear() - { - // TODO - } - - public static void GetSalesPerDay() - { - // TODO - } - - public static void GetSalesPerWeek() - { - // TODO - } -} diff --git a/KebPOS/Services/ShoppingService.cs b/KebPOS/Services/ShoppingService.cs deleted file mode 100644 index 9a756b9..0000000 --- a/KebPOS/Services/ShoppingService.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace KebPOS.Services; - -public class ShoppingService -{ - public void GetProducts() - { - var kebabController = new KebabController(); - var products = kebabController.GetProducts(); - foreach (var product in products) - { - Console.WriteLine(product.Id); - Console.WriteLine(product.Name); - Console.WriteLine(product.Description); - Console.WriteLine(product.Price); - } - } - - public void GetOrders() - { - var kebabController = new KebabController(); - var orders = kebabController.GetOrders(); - foreach (var order in orders) - { - Console.WriteLine(order.Id); - Console.WriteLine(order.OrderDate); - Console.WriteLine(order.TotalPrice); - } - } -} \ No newline at end of file diff --git a/KebPOS/UserInput.cs b/KebPOS/UserInput.cs deleted file mode 100644 index fe5bffc..0000000 --- a/KebPOS/UserInput.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace KebPOS; - -public class UserInput -{ - public int GetId() - { - var id = Console.ReadLine(); - if (id == "back") - { - return -1; - } - - while (!Validation.IsValidIdInput(id)) - { - id = Console.ReadLine(); - if (id == "back") - { - return -1; - } - } - - return int.Parse(id); - } - - public string GetValidAnswer() - { - var answer = Console.ReadLine(); - while (!Validation.IsValidAnswer(answer)) - { - answer = Console.ReadLine(); - } - - return answer; - } - - public int GetQuantity() - { - var input = Console.ReadLine(); - if (input == "back") - { - return -1; - } - - while (!Validation.IsValidIdInput(input)) - { - input = Console.ReadLine(); - if (input == "back") - { - return -1; - } - } - - return int.Parse(input); - } -} \ No newline at end of file diff --git a/KebPOS/UserInterface.cs b/KebPOS/UserInterface.cs deleted file mode 100644 index 42cc571..0000000 --- a/KebPOS/UserInterface.cs +++ /dev/null @@ -1,493 +0,0 @@ -using KebPOS.Models; -using KebPOS.Models.Dtos; -using KebPOS.Services; -using Spectre.Console; -using static KebPOS.Models.Enums; - -namespace KebPOS; - -public class UserInterface -{ - private readonly KebabController _kebabController = new(); - private readonly UserInput _userInput = new(); - - internal void InitializeMenu() - { - bool closeMenu = false; - - while (closeMenu == false) - { - var selection = AnsiConsole.Prompt( - new SelectionPrompt() - .Title("Welcome to [green]KebPOS[/]\nWhat would you like to do?") - .PageSize(10) - .MoreChoicesText("") - .AddChoices(MainMenuSelections.NewOrder, - MainMenuSelections.ViewOrders, - MainMenuSelections.ViewOrderDetails, - MainMenuSelections.DeleteOrder, - MainMenuSelections.ManageProducts, - MainMenuSelections.ViewReports, - MainMenuSelections.CloseApplication)); - - switch (selection) - { - case MainMenuSelections.CloseApplication: - closeMenu = true; - break; - case MainMenuSelections.NewOrder: - AddNewOrder(); - break; - case MainMenuSelections.ViewOrders: - ViewOrders(_kebabController.GetOrders()); - break; - case MainMenuSelections.ViewOrderDetails: - ViewOrderDetails(); - break; - case MainMenuSelections.DeleteOrder: - DeleteOrder(); - break; - case MainMenuSelections.ManageProducts: - ManageProductsMenu(); - break; - case MainMenuSelections.ViewReports: - ManageReportsMenu(); - break; - } - } - } - - internal void ManageProductsMenu() - { - var selection = AnsiConsole.Prompt( - new SelectionPrompt() - .Title("[Purple] Manage Products Menu[/]\nWhat would you like to do?") - .PageSize(10) - .MoreChoicesText("") - .AddChoices(ManageProductsSelections.ViewProducts, - ManageProductsSelections.ViewProductDetails, - ManageProductsSelections.AddProduct, - ManageProductsSelections.UpdateProduct, - ManageProductsSelections.DeleteProduct, - ManageProductsSelections.ReturnToMainMenu)); - - switch (selection) - { - case ManageProductsSelections.ViewProducts: - //added for testing - List products = ProductService.GetProductsFromDatabase(); - DisplayProducts(products); - //added for testing - break; - case ManageProductsSelections.ViewProductDetails: - //add method - break; - case ManageProductsSelections.AddProduct: - ProductService.InsertProduct(); - break; - case ManageProductsSelections.UpdateProduct: - UpdateProduct(); - break; - case ManageProductsSelections.DeleteProduct: - //add method - break; - case ManageProductsSelections.ReturnToMainMenu: - InitializeMenu(); - break; - } - - } - - internal void ManageReportsMenu() - { - var selection = AnsiConsole.Prompt( - new SelectionPrompt() - .Title("[Purple] Manage Reports Menu[/]\nWhich time period do you want to view sales for?") - .PageSize(5) - .MoreChoicesText("") - .AddChoices(ViewReportsSelections.SalesPerMonth, - ViewReportsSelections.SalesPerYear, - ViewReportsSelections.SalesPerDay, - ViewReportsSelections.SalesPerWeek, - ViewReportsSelections.ReturnToMainMenu)); - - switch (selection) - { - case ViewReportsSelections.SalesPerMonth: - ReportsService.GetSalesPerMonth(); - break; - case ViewReportsSelections.SalesPerYear: - ReportsService.GetSalesPerYear(); - break; - case ViewReportsSelections.SalesPerDay: - ReportsService.GetSalesPerDay(); - break; - case ViewReportsSelections.SalesPerWeek: - ReportsService.GetSalesPerWeek(); - break; - case ViewReportsSelections.ReturnToMainMenu: - InitializeMenu(); - break; - } - } - - private void UpdateProduct() - { - var products = _kebabController.GetProducts(); - var productsNameList=products.Select(x => x.Name).ToList(); - var selectedProductName = AnsiConsole.Prompt(new SelectionPrompt(). - Title("[Purple]Select product[/]"). - AddChoices(productsNameList)); - Product productToUpdate=products.Single(x=> x.Name==selectedProductName); - var propertyToUpdate = AnsiConsole.Prompt(new SelectionPrompt() - .Title("[Purple]Select property to update[/]") - .AddChoices( - ProductProperties.Name, - ProductProperties.Description, - ProductProperties.Price, - ProductProperties.MainMenu)); - - switch(propertyToUpdate) - { - case ProductProperties.Name: - UpdateProductName(productToUpdate); - break; - case ProductProperties.Description: - UpdateProductDescription(productToUpdate); - break; - case ProductProperties.Price: - UpdateProductPrice(productToUpdate); - break; - case ProductProperties.MainMenu: - break; - } - } - - private void UpdateProductName(Product productToUpdate) - { - AnsiConsole.Markup($"[Blue]Current name:[/] {productToUpdate.Name}\n\n"); - string newName = AnsiConsole.Ask("[Yellow]Enter new name:[/] "); - _kebabController.UpdateProductName(productToUpdate, newName); - } - - private void UpdateProductDescription(Product productToUpdate) - { - AnsiConsole.Markup($"[Blue]Current description:[/] {productToUpdate.Description}\n\n"); - string newDescription = AnsiConsole.Ask("[Yellow]Enter new description:[/] "); - _kebabController.UpdateProductDescription(productToUpdate, newDescription); - } - - private void UpdateProductPrice(Product productToUpdate) - { - AnsiConsole.Markup($"[Blue]Current price:[/] {productToUpdate.Price}"); - decimal newPrice = AnsiConsole.Ask("[Yellow]Enter new price:[/] "); - _kebabController.UpdateProductPrice(productToUpdate, newPrice); - } - private void DeleteOrder() // Buray kodluyorsun - { - ViewOrders(_kebabController.GetOrders()); - bool validId = false; - var allOrders = _kebabController.GetOrders(); - int selectedOrderId = 0; - - do - { - selectedOrderId = AnsiConsole.Ask("Enter the Id of order to be deleted."); - validId = Validation.IsValidOrderId(selectedOrderId, allOrders); - if (!validId) - Console.WriteLine("Please enter a valid Id"); - - } while (!validId); - - var areYouSure = AnsiConsole.Confirm($"[Red] This will delete the order[/] [yellow]#{selectedOrderId}[/][red] Are you SURE?[/]", false); - if (!areYouSure) - { - Console.Clear(); - return; - } - - var toBeDeleted = allOrders[selectedOrderId - 1]; - _kebabController.RemoveOrder(toBeDeleted); - } - private void AddNewOrder() - { - Dictionary productQuantityPairs = new(); - - decimal totalPrice = 0; - - string answer; - do - { - var products = _kebabController.GetProducts(); - - var productDtoList = MapProductListToProductDtoList(products); - - DisplayProducts(productDtoList); - - var id = GetSelectedProduct(products); - if (id == -1) // user canceled - { - Console.Clear(); - break; - } - - var quantity = GetProductQuantity(); - - if (quantity == -1) // user canceled - { - Console.Clear(); - break; - } - - if (productQuantityPairs.ContainsKey(id)) - { - productQuantityPairs[id] += quantity; - totalPrice += GetPrice(id, products) * quantity; - } - else - { - productQuantityPairs[id] = quantity; - totalPrice += GetPrice(id, products) * quantity; - } - } while (AnsiConsole.Confirm("Do you want to add another product to your order?")); - - var order = CreateNewOrder(totalPrice); - - var orderProductsList = GetOrderProductList(productQuantityPairs, order); - - _kebabController.AddOrders(orderProductsList); - } - - private int GetProductQuantity() - { - Console.Write("How many do you want to add to your order? ('back' to cancel): "); - var quantity = _userInput.GetQuantity(); - - return quantity; - } - - private Order CreateNewOrder(decimal totalPrice) - { - return new Order - { - OrderDate = DateTime.Now, - TotalPrice = totalPrice, - }; - } - - private List GetOrderProductList(Dictionary productQuantityPairs, Order order) - { - List orderProductsList = new(); - - foreach (var productId in productQuantityPairs.Keys) - { - var orderProduct = new OrderProduct - { - ProductId = productId, - Order = order, - Quantity = productQuantityPairs[productId] - }; - - orderProductsList.Add(orderProduct); - } - - return orderProductsList; - } - - private decimal GetPrice(int id, List products) - { - var price = products.First(p => p.Id == id).Price; - - return price; - } - - private int GetSelectedProduct(List products) - { - Console.Write("Select a product by Id to add to cart ('back' to cancel): "); - var id = _userInput.GetId(); - - if (id == -1) // user canceled - { - return -1; - } - - while (!products.Exists(p => p.Id == id)) - { - Console.Write("Select a product by Id to add to cart ('back' to cancel): "); - id = _userInput.GetId(); - if (id == -1) // user canceled - { - return -1; - } - } - - return id; - } - - private void ViewOrders(List orders) - { - DisplayOrders(orders); - } - - private void ViewOrderDetails() - { - List orders = _kebabController.GetOrders(); - - ViewOrders(orders); - - Console.Write("\nSelect an order by its index to view the order details: "); - var index = _userInput.GetId(); - - Order order = new(); - try - { - index = orders[index - 1].Id; - order = orders.FirstOrDefault(x => x.Id == index); - } - catch (ArgumentOutOfRangeException) - { - Console.WriteLine($"Order with the index '{index}' does not exist. Press any key to try again..."); - Console.ReadLine(); - ViewOrderDetails(); - } - - DisplayOrderDetails(order); - - Console.Write("Do you want to view another orders, order details? yes/no: "); - string answer = _userInput.GetValidAnswer(); - - if (answer == "y" || answer == "yes") - { - ViewOrderDetails(); - } - } - - private ProductDto MapProductToProductDto(Product product) - { - return new ProductDto - { - Id = product.Id, - Name = product.Name, - Price = product.Price - }; - } - - private List MapProductListToProductDtoList(List productList) - { - var productDtoList = new List(); - - foreach (var product in productList) - { - productDtoList.Add(MapProductToProductDto(product)); - } - - return productDtoList; - } - - public void DisplayProducts(List products) - { - var productTable = new Table().Centered(); - - var blue = "blue"; - var yellow = "yellow"; - var red = "red"; - - productTable.AddColumns( - new TableColumn($"[{blue}]Id[/]"), - new TableColumn($"[{blue}]Name[/]"), - new TableColumn($"[{blue}]Price[/]") - ); - - foreach (var product in products) - { - productTable.AddRow(new List - { - new (product.Id.ToString()), - new ($"[{yellow}]{product.Name}[/]"), - new ($"[{red}]{product.Price}[/]") - }); - - productTable.AddEmptyRow(); - productTable.AddEmptyRow(); - } - - AnsiConsole.Write(productTable); - } -// added for testing - public void DisplayProducts(List products) - { - var productTable = new Table().Centered(); - - var blue = "blue"; - var yellow = "yellow"; - var red = "red"; - - productTable.AddColumns( - new TableColumn($"[{blue}]Id[/]"), - new TableColumn($"[{blue}]Name[/]"), - new TableColumn($"[{blue}]Price[/]") - ); - - foreach (var product in products) - { - productTable.AddRow(new List - { - new (product.Id.ToString()), - new ($"[{yellow}]{product.Name}[/]"), - new ($"[{red}]{product.Price}[/]") - }); - - productTable.AddEmptyRow(); - productTable.AddEmptyRow(); - } - - AnsiConsole.Write(productTable); - } -//end add - public void DisplayOrders(List orders) - { - var orderTable = new Table().Centered(); - - var blue = "blue"; - var yellow = "yellow"; - var red = "red"; - - orderTable.AddColumns( - new TableColumn($"[{blue}]Id[/]"), - new TableColumn($"[{blue}]Order Date[/]"), - new TableColumn($"[{blue}]Total Price[/]") - ); - - foreach (var order in orders) - { - orderTable.AddRow(new List - { - new ($"#{orders.IndexOf(order) + 1}"), - new ($"[{yellow}]{order.OrderDate}[/]"), - new ($"[{red}]{order.TotalPrice}[/]") - }); - - orderTable.AddEmptyRow(); - orderTable.AddEmptyRow(); - } - - AnsiConsole.Write(orderTable); - } - - public void DisplayOrderDetails(Order order) - { - var orderDetails = $"[Orange3]Id: #{order.Id}[/] [Gold3]Date: {order.OrderDate}[/]\n"; - orderDetails += $@"[Mediumpurple2]Orders ----------------[/]"; - foreach (var item in order.OrderProducts) - { - orderDetails += string.Format("\n[mediumorchid1]{0}x - {1} - ${2}\n[/] ", item.Quantity, item.Product.Name.PadRight(15), item.Product.Price); - } - orderDetails += string.Format("\n[aquamarine1_1]{0}{1:c}[/]", "Total price:".PadRight(18), order.TotalPrice); - var panel = new Panel(orderDetails); - panel.Header = new PanelHeader("[Green]Order Details[/]"); - panel.Border = BoxBorder.Rounded; - panel.Padding = new Padding(2, 2, 2, 2); - AnsiConsole.Write(panel); - } -} diff --git a/KebPOS/Validation.cs b/KebPOS/Validation.cs deleted file mode 100644 index 539b7bf..0000000 --- a/KebPOS/Validation.cs +++ /dev/null @@ -1,61 +0,0 @@ - -using KebPOS.Models; -using KebPOS.Services; - -namespace KebPOS; -public class Validation -{ - public static bool IsValidIdInput(string input) - { - return int.TryParse(input, out int parsedInput) ? parsedInput > 0 : false; - } - - public static bool IsValidAnswer(string? answer) - { - var answersArray = new string[4] { "y", "yes", "n", "no" }; - - return !string.IsNullOrWhiteSpace(answer) && answersArray.Contains(answer); - } - - public static bool IsValidOrderId(int id, IEnumerable orders) - { - int maxId = orders.Count(); - if (id <= 0 || id > maxId) - return false; - else - return true; - } - - public static bool CheckStringLength(string stringToCheck, int nameLengthLimit) - { - bool valid = false; - if (stringToCheck.Length < nameLengthLimit) - { valid = true; } - return valid; - } - - public static bool CheckDuplicateProductName(Product product) - { - bool isDuplicate = true; - List dbproducts = ProductService.GetProductsFromDatabase(); - - isDuplicate = dbproducts.Any(p => String.Equals(p.Name.Trim(), product.Name.Trim(), StringComparison.OrdinalIgnoreCase)); - return isDuplicate; - } - - // User might have a loss leader or sale item you want to ring up for zero - // but want to track. ie: water cups - // -- So I make sure it just can't be negative - public static bool CheckPrice(decimal price) - { - bool valid = price >= 0; - return valid; - } - - public static bool CheckValid(decimal price) - { - int decimalPlaces = BitConverter.GetBytes(decimal.GetBits(price)[3])[2]; - - return decimalPlaces <= 2; - } -} diff --git a/KebPOSTests/KebPOSTests.csproj b/KebPOSTests/KebPOSTests.csproj deleted file mode 100644 index dabfeaa..0000000 --- a/KebPOSTests/KebPOSTests.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net7.0 - enable - enable - - false - - - - - - - - - - - - - - - diff --git a/KebPOSTests/Usings.cs b/KebPOSTests/Usings.cs deleted file mode 100644 index cefced4..0000000 --- a/KebPOSTests/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using NUnit.Framework; \ No newline at end of file diff --git a/KebPOSTests/ValidationTest.cs b/KebPOSTests/ValidationTest.cs deleted file mode 100644 index 3351015..0000000 --- a/KebPOSTests/ValidationTest.cs +++ /dev/null @@ -1,188 +0,0 @@ -using KebPOS; -using KebPOS.Models; - -namespace KebPOSTests; - -[TestFixture] -public class ValidationTest -{ - [TestCase("13")] - [TestCase("1")] - [TestCase("17")] - [TestCase("300")] - public void IsValidIdInput_ShouldReturnTrue(string id) - { - var result = Validation.IsValidIdInput(id); - - Assert.IsTrue(result); - } - - [TestCase("0")] - [TestCase("-3")] - [TestCase("-99")] - [TestCase("-1")] - [TestCase("")] - [TestCase("hello world")] - [TestCase("36854775807")] - [TestCase(" ")] - public void IsValidIdInput_ShouldReturnFalse(string id) - { - var result = Validation.IsValidIdInput(id); - - Assert.IsFalse(result); - } - - [TestCase("y")] - [TestCase("yes")] - [TestCase("n")] - [TestCase("no")] - public void IsValidAnswer_ShouldReturnTrue(string input) - { - var result = Validation.IsValidAnswer(input); - - Assert.IsTrue(result); - } - - [TestCase("")] - [TestCase(" ")] - [TestCase("!*&")] - [TestCase("faf")] - [TestCase(" bacon")] - [TestCase("ham ")] - [TestCase(" eggs ")] - [TestCase("-111")] - [TestCase("12")] - [TestCase("yess")] - [TestCase("noo")] - [TestCase("Y")] - [TestCase("Yes")] - [TestCase("YeS")] - [TestCase("yeS")] - [TestCase("N")] - [TestCase("NO")] - [TestCase(" yes")] - [TestCase("n ")] - [TestCase(" no ")] - [TestCase("n0")] - [TestCase("y3s")] - public void IsValidAnswer_ShouldReturnFalse(string input) - { - var result = Validation.IsValidAnswer(input); - - Assert.IsFalse(result); - } - - [Test] - public void CheckStringLength_ValidLength_ReturnsTrue() - { - //Arrange - string stringToCheck = "SampleProduct"; - int nameLengthLimit = 15; - //Act - bool result = Validation.CheckStringLength(stringToCheck, nameLengthLimit); - //Assert - Assert.IsTrue(result); - } - [Test] - public void CheckStringLength_ValidLength_ReturnsFalse() - { - //Arrange - string stringToCheck = "SampleProduct"; - int nameLengthLimit = 12; - //Act - bool result = Validation.CheckStringLength(stringToCheck, nameLengthLimit); - //Assert - Assert.IsFalse(result); - } - [Test] - public void CheckDuplicateProductName_ReturnsTrue() - { - //Arrange - Product product = new Product(); - product.Name = "Yogurt Kebab"; - - //Act - bool result = Validation.CheckDuplicateProductName(product); - - //Assert - Assert.IsTrue(result); - } - [Test] - public void CheckDuplicateProductName_ReturnsFalse() - { - //Arrange - Product product = new Product(); - product.Name = "There should not be a product with this name"; - - //Act - bool result = Validation.CheckDuplicateProductName(product); - - //Assert - Assert.IsFalse(result); - } - - [Test] - public void CheckValid_ReturnTrue() - { - //Arrange - decimal price = (decimal)10.01; - - //Act - bool result = Validation.CheckValid(price); - - //Assert - Assert.IsTrue(result); - } - - [Test] - public void CheckValid_ReturnFalse() - { - //Arrange - decimal price = (decimal)10.123; - - //Act - bool result = Validation.CheckValid(price); - - //Assert - Assert.IsFalse(result); - - } - - [Test] - public void CheckPrice_PosPrice_ReturnsTrue() - { - // Arrange - decimal validPrice = (decimal)10.00; - - // Act - bool result = Validation.CheckPrice(validPrice); - - // Assert - Assert.IsTrue(result); - } - - [Test] - public void CheckPrice_NegativePrice_ReturnsFalse() - { - // Arrange - decimal invalidPrice = (decimal)-5.00; - - // Act - bool result = Validation.CheckPrice(invalidPrice); - - // Assert - Assert.IsFalse(result); - } - [Test] - public void CheckPrice_NonNegativePrice_ReturnsTrue() - { - // Arrange - decimal validPrice = (decimal)0.00; - - // Act - bool result = Validation.CheckPrice(validPrice); - - // Assert - Assert.IsTrue(result); - } -} \ No newline at end of file diff --git a/PointOfSale.RyanW84/Controllers/CategoryController.cs b/PointOfSale.RyanW84/Controllers/CategoryController.cs new file mode 100644 index 0000000..5839c70 --- /dev/null +++ b/PointOfSale.RyanW84/Controllers/CategoryController.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore; +using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.RyanW84.RyanW84; + +namespace PointOfSale.EntityFramework.RyanW84.Controllers; + +internal class CategoryController + { + internal static void AddCategory(Category category) + { + using var db = new ProductsContext(); + + db.Add(category); + + db.SaveChanges(); + } + + internal static void DeleteCategory(Category category) + { + using var db = new ProductsContext(); + + db.Remove(category); + + db.SaveChanges(); + } + + internal static void UpdateCategory(Category category) + { + using var db = new ProductsContext(); + + db.Update(category); + + db.SaveChanges(); + } + + internal static List GetCategories() + { + using var db = new ProductsContext(); + + var categories = db.Categories + .Include(x => x.Products) + .ToList(); + + return categories; + } + } + diff --git a/PointOfSale.RyanW84/Controllers/OrderController.cs b/PointOfSale.RyanW84/Controllers/OrderController.cs new file mode 100644 index 0000000..972fda8 --- /dev/null +++ b/PointOfSale.RyanW84/Controllers/OrderController.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore; +using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.RyanW84.RyanW84; + +namespace PointOfSale.EntityFramework.RyanW84.Controllers; + +internal class OrderController + { + internal static void AddOrder(List orders) + { + using var db = new ProductsContext(); + + db.OrderProducts.AddRange(orders); + + db.SaveChanges(); + } + + internal static List GetOrders() + { + using var db = new ProductsContext(); + var ordersList = db.Orders + .Include(o => o.OrderProducts) + .ThenInclude(op => op.Product) + .ThenInclude(p => p.Category) + .ToList(); + + return ordersList; + } + } + diff --git a/PointOfSale.RyanW84/Controllers/ProductController.cs b/PointOfSale.RyanW84/Controllers/ProductController.cs new file mode 100644 index 0000000..175c6ef --- /dev/null +++ b/PointOfSale.RyanW84/Controllers/ProductController.cs @@ -0,0 +1,61 @@ +using Microsoft.EntityFrameworkCore; +using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.RyanW84.RyanW84; + +namespace PointOfSale.EntityFramework.RyanW84.Controllers; + +internal class ProductController + { + internal static void AddProduct(Product product) + { + + using var db = new ProductsContext(); + db.Add(product); + db.SaveChanges(); + } + + internal static void DeleteProduct(Product product) + { + using var db = new ProductsContext(); + db.Remove(product); + db.SaveChanges(); + } + internal static void UpdateProduct(Product product) + { + using var db = new ProductsContext(); + + db.Update(product); + + db.SaveChanges(); + } + + + internal static Product GetProductById(int id) + { + using var db = new ProductsContext(); + var product = db.Products + .Include(x => x.Category) + .SingleOrDefault(x => x.ProductId == id); + + return product; + } + + internal static List GetProducts() + { + using var db = new ProductsContext(); + + var products = db.Products + .Include(x => x.Category) + .ToList(); + + return products; + } + + + + + + + + } + diff --git a/PointOfSale.RyanW84/Enums.cs b/PointOfSale.RyanW84/Enums.cs new file mode 100644 index 0000000..969c3b4 --- /dev/null +++ b/PointOfSale.RyanW84/Enums.cs @@ -0,0 +1,64 @@ +using System.ComponentModel.DataAnnotations; + +namespace PointOfSale.EntityFramework.RyanW84; + +internal class Enums + { + internal enum MainMenuOptions + { + [Display(Name = "Manage Categories")] + ManageCategories, + [Display(Name = "Manage Products")] + ManageProducts, + [Display(Name = "Manage Orders")] + ManagerOrders, + [Display(Name = "Generate Report")] + GenerateReport, + [Display(Name = "Quit")] + Quit + } + + internal enum CategoryMenu + { + [Display(Name = "Add Category")] + AddCategory, + [Display(Name = "Delete Category")] + DeleteCategory, + [Display(Name = "View Category")] + ViewCategory, + [Display(Name = "View All Categories")] + ViewAllCategories, + [Display(Name = "Update Category")] + UpdateCategory, + [Display(Name = "Go Back")] + GoBack + } + + internal enum ProductMenu + { + [Display(Name = "Add Product")] + AddProduct, + [Display(Name = "Delete Product")] + DeleteProduct, + [Display(Name = "Update Product")] + UpdateProduct, + [Display(Name = "View Product")] + ViewProduct, + [Display(Name = "View All Products")] + ViewAllProducts, + [Display(Name = "Go Back")] + GoBack + } + + internal enum OrderMenu + { + [Display(Name = "Add Order")] + AddOrder, + [Display(Name = "View Order")] + ViewOrder, + [Display(Name = "View All Orders")] + ViewAllOrders, + [Display(Name = "Go Back")] + GoBack, + } + } diff --git a/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs b/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs new file mode 100644 index 0000000..4becba5 --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs @@ -0,0 +1,48 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.RyanW84.RyanW84; + +#nullable disable + +namespace PointOfSale.EntityFramework.RyanW84.Migrations +{ + [DbContext(typeof(ProductsContext))] + [Migration("20250404125218_initial-migration")] + partial class initialmigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.3"); + + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Product", b => + { + b.Property("ProductId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("TEXT"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.HasKey("ProductId"); + + b.ToTable("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.cs b/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.cs new file mode 100644 index 0000000..b25cbc4 --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PointOfSale.EntityFramework.RyanW84.Migrations +{ + /// + public partial class initialmigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: true), + Description = table.Column(type: "TEXT", nullable: true), + Price = table.Column(type: "TEXT", nullable: false), + ProductId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Products"); + } + } +} diff --git a/PointOfSale.RyanW84/Migrations/20250405121706_add-price.Designer.cs b/PointOfSale.RyanW84/Migrations/20250405121706_add-price.Designer.cs new file mode 100644 index 0000000..a7bce60 --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/20250405121706_add-price.Designer.cs @@ -0,0 +1,48 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.RyanW84.RyanW84; + +#nullable disable + +namespace PointOfSale.EntityFramework.RyanW84.Migrations +{ + [DbContext(typeof(ProductsContext))] + [Migration("20250405121706_add-price")] + partial class addprice + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.3"); + + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Product", b => + { + b.Property("ProductId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("TEXT"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.HasKey("ProductId"); + + b.ToTable("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/KebPOS/Migrations/20240112084734_InitialCreate.cs b/PointOfSale.RyanW84/Migrations/20250405121706_add-price.cs similarity index 77% rename from KebPOS/Migrations/20240112084734_InitialCreate.cs rename to PointOfSale.RyanW84/Migrations/20250405121706_add-price.cs index f005293..c3db13e 100644 --- a/KebPOS/Migrations/20240112084734_InitialCreate.cs +++ b/PointOfSale.RyanW84/Migrations/20250405121706_add-price.cs @@ -2,10 +2,10 @@ #nullable disable -namespace KebPOS.Migrations +namespace PointOfSale.EntityFramework.RyanW84.Migrations { /// - public partial class InitialCreate : Migration + public partial class addprice : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) diff --git a/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.Designer.cs b/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.Designer.cs new file mode 100644 index 0000000..f0272d2 --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.Designer.cs @@ -0,0 +1,85 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.RyanW84.RyanW84; + +#nullable disable + +namespace PointOfSale.EntityFramework.RyanW84.Migrations +{ + [DbContext(typeof(ProductsContext))] + [Migration("20250405201819_Create-Category")] + partial class CreateCategory + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.3"); + + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Models.Category", b => + { + b.Property("CategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("CategoryId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Categories"); + }); + + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Models.Product", b => + { + b.Property("ProductId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CategoryId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("TEXT"); + + b.HasKey("ProductId"); + + b.HasIndex("CategoryId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Models.Product", b => + { + b.HasOne("PointOfSale.EntityFramework.RyanW84.Models.Category", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Models.Category", b => + { + b.Navigation("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.cs b/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.cs new file mode 100644 index 0000000..eafb765 --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.cs @@ -0,0 +1,110 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PointOfSale.EntityFramework.RyanW84.Migrations +{ + /// + public partial class CreateCategory : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Description", + table: "Products"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Products", + type: "TEXT", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "CategoryId", + table: "Products", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "Categories", + columns: table => new + { + CategoryId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Categories", x => x.CategoryId); + }); + + migrationBuilder.CreateIndex( + name: "IX_Products_CategoryId", + table: "Products", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_Products_Name", + table: "Products", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Categories_Name", + table: "Categories", + column: "Name", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_Products_Categories_CategoryId", + table: "Products", + column: "CategoryId", + principalTable: "Categories", + principalColumn: "CategoryId", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Products_Categories_CategoryId", + table: "Products"); + + migrationBuilder.DropTable( + name: "Categories"); + + migrationBuilder.DropIndex( + name: "IX_Products_CategoryId", + table: "Products"); + + migrationBuilder.DropIndex( + name: "IX_Products_Name", + table: "Products"); + + migrationBuilder.DropColumn( + name: "CategoryId", + table: "Products"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Products", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT"); + + migrationBuilder.AddColumn( + name: "Description", + table: "Products", + type: "TEXT", + nullable: true); + } + } +} diff --git a/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs b/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs new file mode 100644 index 0000000..9aba633 --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs @@ -0,0 +1,82 @@ + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.RyanW84.RyanW84; + +#nullable disable + +namespace PointOfSale.EntityFramework.RyanW84.Migrations +{ + [DbContext(typeof(ProductsContext))] + partial class ProductsContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.3"); + + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Models.Category", b => + { + b.Property("CategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("CategoryId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Categories"); + }); + + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Models.Product", b => + { + b.Property("ProductId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CategoryId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("TEXT"); + + b.HasKey("ProductId"); + + b.HasIndex("CategoryId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Models.Product", b => + { + b.HasOne("PointOfSale.EntityFramework.RyanW84.Models.Category", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Models.Category", b => + { + b.Navigation("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PointOfSale.RyanW84/Models/Category.cs b/PointOfSale.RyanW84/Models/Category.cs new file mode 100644 index 0000000..2a5f180 --- /dev/null +++ b/PointOfSale.RyanW84/Models/Category.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +using Microsoft.EntityFrameworkCore; + +namespace PointOfSale.EntityFramework.RyanW84.Models; + + +internal class Category + { + public int CategoryId { get; set; } + + public string Name { get; set; } + + public List Products { get; set; } + } + diff --git a/PointOfSale.RyanW84/Models/DTOs/MonthlyReportDTO.cs b/PointOfSale.RyanW84/Models/DTOs/MonthlyReportDTO.cs new file mode 100644 index 0000000..623492f --- /dev/null +++ b/PointOfSale.RyanW84/Models/DTOs/MonthlyReportDTO.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PointOfSale.EntityFramework.RyanW84.Models.DTOs; + +internal class MonthlyReportDTO + { + public string Month { get; set; } + public decimal TotalPrice { get; set; } + public int TotalQuantity { get; set; } + } + diff --git a/PointOfSale.RyanW84/Models/DTOs/ProductForOrderViewDTO.cs b/PointOfSale.RyanW84/Models/DTOs/ProductForOrderViewDTO.cs new file mode 100644 index 0000000..42de630 --- /dev/null +++ b/PointOfSale.RyanW84/Models/DTOs/ProductForOrderViewDTO.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PointOfSale.EntityFramework.RyanW84.Models.DTOs; + +internal class ProductForOrderViewDTO + { + public int Id { get; set; } + public string Name { get; set; } + public string CategoryName { get; set; } + public int Quantity { get; set; } + public decimal Price { get; set; } + public decimal TotalPrice { get; set; } + } + diff --git a/PointOfSale.RyanW84/Models/Order.cs b/PointOfSale.RyanW84/Models/Order.cs new file mode 100644 index 0000000..33b980a --- /dev/null +++ b/PointOfSale.RyanW84/Models/Order.cs @@ -0,0 +1,12 @@ +namespace PointOfSale.EntityFramework.RyanW84.Models; + +internal class Order + { + public int OrderId { get; set; } + public decimal TotalPrice { get; set; } + public DateTime CreatedDate { get; set; } + public DateTime UpdatedDate { get; set; } + + public ICollection OrderProducts { get; set; } + } + diff --git a/PointOfSale.RyanW84/Models/OrderProduct.cs b/PointOfSale.RyanW84/Models/OrderProduct.cs new file mode 100644 index 0000000..9005434 --- /dev/null +++ b/PointOfSale.RyanW84/Models/OrderProduct.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PointOfSale.EntityFramework.RyanW84.Models; + +internal class OrderProduct + { + public int OrderId { get; set; } + public Order Order { get; set; } + public int ProductId { get; set; } + public Product Product { get; set; } + public int Quantity { get; set; } + public int UnitPrice { get; set; } + } + diff --git a/PointOfSale.RyanW84/Models/Product.cs b/PointOfSale.RyanW84/Models/Product.cs new file mode 100644 index 0000000..579aea4 --- /dev/null +++ b/PointOfSale.RyanW84/Models/Product.cs @@ -0,0 +1,25 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +using Microsoft.EntityFrameworkCore; + +namespace PointOfSale.EntityFramework.RyanW84.Models; + +[Index(nameof(Name), IsUnique = true)] +internal class Product + { + + public int ProductId { get; set; } + + + public string Name { get; set; } + + public decimal Price { get; set; } + + public int CategoryId { get; set; } + + public Category Category { get; set; } + + public ICollection OrderProducts { get; set; } + } + diff --git a/KebPOS/KebPOS.csproj b/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.csproj similarity index 60% rename from KebPOS/KebPOS.csproj rename to PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.csproj index e54d7b7..ee7a2b8 100644 --- a/KebPOS/KebPOS.csproj +++ b/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.csproj @@ -1,26 +1,21 @@ - - - - Exe - net7.0 - enable - enable - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - Always - - - - + + + + Exe + net9.0 + enable + disable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + diff --git a/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.sln b/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.sln new file mode 100644 index 0000000..f4e2c68 --- /dev/null +++ b/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35919.96 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointOfSale.EntityFramework.RyanW84", "PointOfSale.EntityFramework.RyanW84.csproj", "{DC9E8356-9FA1-4022-A813-D13E7A944E83}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DC9E8356-9FA1-4022-A813-D13E7A944E83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC9E8356-9FA1-4022-A813-D13E7A944E83}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC9E8356-9FA1-4022-A813-D13E7A944E83}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC9E8356-9FA1-4022-A813-D13E7A944E83}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {601BF194-5546-4A56-982C-9E95136A53E9} + EndGlobalSection +EndGlobal diff --git a/PointOfSale.RyanW84/ProductsContext.cs b/PointOfSale.RyanW84/ProductsContext.cs new file mode 100644 index 0000000..42340a0 --- /dev/null +++ b/PointOfSale.RyanW84/ProductsContext.cs @@ -0,0 +1,477 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.EntityFramework.RyanW84; + +namespace PointOfSale.RyanW84.RyanW84; + +internal class ProductsContext : DbContext + { + public DbSet Products { get; set; } + public DbSet Categories { get; set; } + public DbSet Orders { get; set; } + public DbSet OrderProducts { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => + optionsBuilder + .UseSqlite($"Data Source = products.db") + .EnableSensitiveDataLogging() + .UseLoggerFactory(GetLoggerFactory()); + + private ILoggerFactory GetLoggerFactory() + { + var loggerFactory = LoggerFactory.Create(builder => + { + builder.AddConsole(); + builder.AddFilter((category, level) => + category == DbLoggerCategory.Database.Command.Name && level == LogLevel.Information); + }); + + return loggerFactory; + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasKey(op => new { op.OrderId, op.ProductId }); + + modelBuilder.Entity() + .HasOne(op => op.Order) + .WithMany(o => o.OrderProducts) + .HasForeignKey(op => op.OrderId); + + modelBuilder.Entity() + .HasOne(op => op.Product) + .WithMany(o => o.OrderProducts) + .HasForeignKey(op => op.ProductId); + + modelBuilder.Entity() + .HasOne(p => p.Category) + .WithMany(o => o.Products) + .HasForeignKey(p => p.CategoryId); + + modelBuilder.Entity() + .HasData(new List + { + new() { + CategoryId = 1, + Name = "Coffee" + }, + new() { + CategoryId = 2, + Name = "Juice" + }, + new() { + CategoryId = 3, + Name = "Pastry" + }, + new() { + CategoryId = 4, + Name = "Loot" + } + }); + + modelBuilder.Entity() + .HasData(new List + { + new() { + ProductId = 1, + CategoryId = 1, + Name = "Cappuccino", + Price = 13.0m + }, + new() { + ProductId = 2, + CategoryId = 1, + Name = "Latte", + Price = 5.0m + }, + new() { + ProductId = 3, + CategoryId = 2, + Name = "Apple Juice", + Price = 13.0m + }, + new() { + ProductId = 4, + CategoryId = 2, + Name = "Orange Juice", + Price = 6.0m + }, + new() { + ProductId = 5, + CategoryId = 3, + Name = "Cheesecake", + Price = 7.0m + }, + new() { + ProductId = 6, + CategoryId = 3, + Name = "Beefcake", + Price = 9.0m + }, + new() { + ProductId = 7, + CategoryId = 4, + Name = "Super Mug", + Price = 13.0m + }, + new() { + ProductId = 8, + CategoryId = 4, + Name = "Super Keep Cup", + Price = 6.0m + } + }); + + modelBuilder.Entity() + .HasData(new List + { + new() { + OrderId = 1, + CreatedDate = DateTime.Now.AddMonths(-1), + TotalPrice = 70 + }, + new() { + OrderId = 2, + CreatedDate = DateTime.Now.AddMonths(-1), + TotalPrice = 109 + }, + new() { + OrderId = 3, + CreatedDate = DateTime.Now.AddMonths(-1), + TotalPrice = 189 + }, + new() { + OrderId = 4, + CreatedDate = DateTime.Now.AddMonths(-1), + TotalPrice = 23 + }, + new() { + OrderId = 5, + CreatedDate = DateTime.Now.AddMonths(-2), + TotalPrice = 27 + }, + new() { + OrderId = 6, + CreatedDate = DateTime.Now.AddMonths(-2), + TotalPrice = 65 + }, + new() { + OrderId = 7, + CreatedDate = DateTime.Now.AddMonths(-2), + TotalPrice = 5 + }, + new() { + OrderId = 8, + CreatedDate = DateTime.Now.AddMonths(-2), + TotalPrice = 91 + }, + new() { + OrderId = 9, + CreatedDate = DateTime.Now.AddMonths(-2), + TotalPrice = 88 + }, + new() { + OrderId = 10, + CreatedDate = DateTime.Now.AddMonths(-3), + TotalPrice = 91 + }, + new() { + OrderId = 11, + CreatedDate = DateTime.Now.AddMonths(-3), + TotalPrice = 18 + }, + new() { + OrderId = 12, + CreatedDate = DateTime.Now.AddMonths(-3), + TotalPrice = 23 + }, + new() { + OrderId = 13, + CreatedDate = DateTime.Now.AddMonths(-3), + TotalPrice = 27 + }, + new() { + OrderId = 14, + CreatedDate = DateTime.Now.AddMonths(-3), + TotalPrice = 179 + }, + new() { + OrderId = 15, + CreatedDate = DateTime.Now.AddMonths(-3), + TotalPrice = 202 + }, + new() { + OrderId = 16, + CreatedDate = DateTime.Now.AddMonths(-3), + TotalPrice = 97 + }, + new() { + OrderId = 17, + CreatedDate = DateTime.Now.AddYears(1), + TotalPrice = 70 + }, + new() { + OrderId = 18, + CreatedDate = DateTime.Now.AddYears(1), + TotalPrice = 109 + }, + new() { + OrderId = 19, + CreatedDate = DateTime.Now.AddYears(1), + TotalPrice = 189 + }, + new() { + OrderId = 20, + CreatedDate = DateTime.Now.AddYears(-1), + TotalPrice = 23 + }, + }); + + modelBuilder.Entity() + .HasData(new List + { + new() { + OrderId = 1, + ProductId = 1, + Quantity = 5 + }, + new() { + OrderId = 1, + ProductId = 2, + Quantity = 1 + }, + new() { + OrderId = 2, + ProductId = 3, + Quantity = 7 + }, + new() { + OrderId = 2, + ProductId = 4, + Quantity = 3 + }, + new() { + OrderId = 3, + ProductId = 1, + Quantity = 5 + }, + new() { + OrderId = 3, + ProductId = 2, + Quantity = 1 + }, + new() { + OrderId = 3, + ProductId = 3, + Quantity = 7 + }, + new() { + OrderId = 3, + ProductId = 4, + Quantity = 3 + }, + new() { + OrderId = 4, + ProductId = 5, + Quantity = 2 + }, + new() { + OrderId = 4, + ProductId = 6, + Quantity = 1 + }, + new() { + OrderId = 5, + ProductId = 6, + Quantity = 1 + }, + new() { + OrderId = 5, + ProductId = 8, + Quantity = 3 + }, + new() { + OrderId = 6, + ProductId = 1, + Quantity = 5 + }, + new() { + OrderId = 7, + ProductId = 2, + Quantity = 1 + }, + new() { + OrderId = 8, + ProductId = 3, + Quantity = 7 + }, + new() { + OrderId = 9, + ProductId = 4, + Quantity = 3 + }, + new() { + OrderId = 9, + ProductId = 1, + Quantity = 5 + }, + new() { + OrderId = 9, + ProductId = 2, + Quantity = 1 + }, + new() { + OrderId = 10, + ProductId = 3, + Quantity = 7 + }, + new() { + OrderId = 11, + ProductId = 4, + Quantity = 3 + }, + new() { + OrderId = 12, + ProductId = 5, + Quantity = 2 + }, + new() { + OrderId = 12, + ProductId = 6, + Quantity = 1 + }, + new() { + OrderId = 13, + ProductId = 6, + Quantity = 1 + }, + new() { + OrderId = 13, + ProductId = 8, + Quantity = 3 + }, + new() { + OrderId = 14, + ProductId = 1, + Quantity = 5 + }, + new() { + OrderId = 14, + ProductId = 2, + Quantity = 1 + }, + new() { + OrderId = 14, + ProductId = 3, + Quantity = 7 + }, + new() { + OrderId = 14, + ProductId = 4, + Quantity = 3 + }, + new() { + OrderId = 15, + ProductId = 1, + Quantity = 5 + }, + new() { + OrderId = 15, + ProductId = 2, + Quantity = 1 + }, + new() { + OrderId = 15, + ProductId = 3, + Quantity = 7 + }, + new() { + OrderId = 15, + ProductId = 4, + Quantity = 3 + }, + new() { + OrderId = 15, + ProductId = 5, + Quantity = 2 + }, + new() { + OrderId = 15, + ProductId = 6, + Quantity = 1 + }, + new() { + OrderId = 16, + ProductId = 6, + Quantity = 1 + }, + new() { + OrderId = 16, + ProductId = 8, + Quantity = 3 + }, + new() { + OrderId = 16, + ProductId = 1, + Quantity = 5 + }, + new() { + OrderId = 16, + ProductId = 2, + Quantity = 1 + }, + new() { + OrderId = 17, + ProductId = 1, + Quantity = 5 + }, + new() { + OrderId = 17, + ProductId = 2, + Quantity = 1 + }, + new() { + OrderId = 18, + ProductId = 3, + Quantity = 7 + }, + new() { + OrderId = 18, + ProductId = 4, + Quantity = 3 + }, + new() { + OrderId = 19, + ProductId = 1, + Quantity = 5 + }, + new() { + OrderId = 19, + ProductId = 2, + Quantity = 1 + }, + new() { + OrderId = 19, + ProductId = 3, + Quantity = 7 + }, + new() { + OrderId = 19, + ProductId = 4, + Quantity = 3 + }, + new() { + OrderId = 20, + ProductId = 5, + Quantity = 2 + }, + new() { + OrderId = 20, + ProductId = 6, + Quantity = 1 + }, + }); + } + } \ No newline at end of file diff --git a/PointOfSale.RyanW84/Program.cs b/PointOfSale.RyanW84/Program.cs new file mode 100644 index 0000000..74c1caf --- /dev/null +++ b/PointOfSale.RyanW84/Program.cs @@ -0,0 +1,11 @@ +using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.RyanW84.RyanW84; + + +var context = new ProductsContext(); +context.Database.EnsureDeleted(); +context.Database.EnsureCreated(); + + +UserInterface.MainMenu(); + diff --git a/PointOfSale.RyanW84/Properties/launchSettings.json b/PointOfSale.RyanW84/Properties/launchSettings.json new file mode 100644 index 0000000..57cf763 --- /dev/null +++ b/PointOfSale.RyanW84/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "PointOfSale.RyanW84": { + "commandName": "Project", + "workingDirectory": "C:\\Users\\Ryanw\\OneDrive\\Documents\\GitHub\\CONSOLE.PointOfSale\\PointOfSale.RyanW84" + } + } +} \ No newline at end of file diff --git a/PointOfSale.RyanW84/Services/CategoryService.cs b/PointOfSale.RyanW84/Services/CategoryService.cs new file mode 100644 index 0000000..b8b587a --- /dev/null +++ b/PointOfSale.RyanW84/Services/CategoryService.cs @@ -0,0 +1,53 @@ +using PointOfSale.EntityFramework.RyanW84.Controllers; +using PointOfSale.EntityFramework.RyanW84.Models; + +using Spectre.Console; + +namespace PointOfSale.EntityFramework.RyanW84.Services; + +internal class CategoryService + { + internal static void InsertCategory() + { + var category = new Category(); + category.Name = AnsiConsole.Ask("Category's name:"); + + CategoryController.AddCategory(category); + + } + internal static void DeleteCategory() + { + var category = GetCategoryOptionInput(); + CategoryController.DeleteCategory(category); + } + internal static void UpdateCategory() + { + var category = GetCategoryOptionInput(); + + category.Name = AnsiConsole.Ask("Category's new name:"); + + CategoryController.UpdateCategory(category); + } + internal static Category GetCategoryOptionInput() + { + var categories = CategoryController.GetCategories(); + var categoriesArray = categories.Select(x => x.Name).ToArray(); + var option = AnsiConsole.Prompt(new SelectionPrompt() + .Title("Choose Category") + .AddChoices(categoriesArray)); + var category = categories.Single(x => x.Name == option); + + return category; + } + internal static void GetCategories() + { + var categories = CategoryController.GetCategories(); + UserInterface.ShowCategoryTable(categories); + } + internal static void GetCategory() + { + var category =GetCategoryOptionInput(); + UserInterface.ShowCategory(category); + } + } + diff --git a/PointOfSale.RyanW84/Services/OrderService.cs b/PointOfSale.RyanW84/Services/OrderService.cs new file mode 100644 index 0000000..4eb27b1 --- /dev/null +++ b/PointOfSale.RyanW84/Services/OrderService.cs @@ -0,0 +1,98 @@ +using PointOfSale.EntityFramework.RyanW84.Controllers; +using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.EntityFramework.RyanW84.Models.DTOs; + +using Spectre.Console; + +namespace PointOfSale.EntityFramework.RyanW84.Services; + +internal class OrderService + { + internal static void InsertOrder() + { + var orderProducts = GetProductsForOrder(); + + OrderController.AddOrder(orderProducts); + } + + internal static void GetOrder() + { + var order = GetOrderOptionInput(); + if (order == null) + { + return; + } + var products = order.OrderProducts + .Select(x => new ProductForOrderViewDTO() + { + Id = x.ProductId, + Name = x.Product.Name, + CategoryName = x.Product.Category.Name, + Quantity = x.Quantity, + Price = x.Product.Price, + TotalPrice = x.Quantity * x.Product.Price + }) + .ToList(); + + UserInterface.ShowOrder(order); + UserInterface.ShowProductForOrderTable(products); + } + + private static Order GetOrderOptionInput() + { + var orders = OrderController.GetOrders(); + if (orders.Count == 0) + { + AnsiConsole.Markup("[red]No orders available![/]"); + Console.WriteLine("\nPress any key to continue..."); + Console.ReadKey(); + return null; + } + var orderArray = orders.Select(x => $"{x.OrderId}.{x.CreatedDate} - {x.TotalPrice}").ToArray(); + var option = AnsiConsole.Prompt(new SelectionPrompt() + .Title("Choose Order") + .AddChoices(orderArray)); + var idArray = option.Split('.'); + var order = orders.Single(x => x.OrderId == Int32.Parse(idArray[0])); + + return order; + } + + internal static void GetOrders() + { + var orders = OrderController.GetOrders(); + + UserInterface.ShowOrderTable(orders); + } + + private static List GetProductsForOrder() + { + var products = new List(); + var order = new Order() + { + CreatedDate = DateTime.Now, + }; + + bool isOrderFinished = false; + + while (!isOrderFinished) + { + var product = ProductService.GetProductOptionInput(); + var quantity = AnsiConsole.Ask("How many?"); + + order.TotalPrice = order.TotalPrice + (quantity * product.Price); + + products.Add( + new OrderProduct + { + Order = order, + ProductId = product.ProductId, + Quantity = quantity + }); + + isOrderFinished = !AnsiConsole.Confirm("Would you like to add more products?"); + } + return products; + } + } + diff --git a/PointOfSale.RyanW84/Services/ProductService.cs b/PointOfSale.RyanW84/Services/ProductService.cs new file mode 100644 index 0000000..56022fb --- /dev/null +++ b/PointOfSale.RyanW84/Services/ProductService.cs @@ -0,0 +1,64 @@ +using PointOfSale.EntityFramework.RyanW84.Controllers; +using PointOfSale.EntityFramework.RyanW84.Models; + +using Spectre.Console; + +namespace PointOfSale.EntityFramework.RyanW84.Services; + +internal class ProductService + { + internal static void InsertProduct() + { + var product = new Product(); + product.Name = AnsiConsole.Ask("Product's name:"); + product.Price = AnsiConsole.Ask("Product's price:"); + product.CategoryId = CategoryService. + GetCategoryOptionInput().CategoryId; + + ProductController.AddProduct(product); + } + internal static void DeleteProduct() + { + var product = GetProductOptionInput(); + ProductController.DeleteProduct(product); + } + internal static void UpdateProduct() + { + var product = GetProductOptionInput(); + + product.Name = AnsiConsole.Confirm("Update Product Name?") ? + AnsiConsole.Ask("Product's new name: ") + : product.Name; + + product.Price = AnsiConsole.Confirm("Update Product Price?") ? + AnsiConsole.Ask("Product's new price: ") + : product.Price; + product.Category = AnsiConsole.Confirm("Update Category?") ? + CategoryService.GetCategoryOptionInput() : product.Category; + + ProductController.UpdateProduct(product); + } + internal static void GetProduct() + { + var product = GetProductOptionInput(); + UserInterface.ShowProduct(product); + } + internal static void GetProducts() + { + var products = ProductController.GetProducts(); + UserInterface.ShowProductTable(products); + } + internal static Product GetProductOptionInput() + { + var products = ProductController.GetProducts(); + var productsArray = products.Select(x => x.Name).ToArray(); + var option = AnsiConsole.Prompt(new SelectionPrompt() + .Title("Choose Product") + .AddChoices(productsArray)); + var id = products.Single(x => x.Name == option).ProductId; + var product = ProductController.GetProductById(id); + + return product; + } + } + diff --git a/PointOfSale.RyanW84/Services/ReportService.cs b/PointOfSale.RyanW84/Services/ReportService.cs new file mode 100644 index 0000000..6e251ac --- /dev/null +++ b/PointOfSale.RyanW84/Services/ReportService.cs @@ -0,0 +1,30 @@ +using System.Globalization; + +using PointOfSale.EntityFramework.RyanW84.Controllers; +using PointOfSale.EntityFramework.RyanW84.Models.DTOs; + +namespace PointOfSale.EntityFramework.RyanW84.Services; + +internal class ReportService + { + internal static void CreateMonthlyReport() + { + var orders = OrderController.GetOrders(); + + var report = orders.GroupBy(x => new //Linq creates anonymous object + { + x.CreatedDate.Month, + x.CreatedDate.Year + }) + .Select(grp => new MonthlyReportDTO + { + //Igrouping links elements by Key + Month =$" {CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(grp.Key.Month)} {grp.Key.Year}", + TotalPrice = grp.Sum(grp => grp.TotalPrice), + TotalQuantity = grp.Sum(x => x.OrderProducts.Sum(x => x.Quantity)) + }).ToList(); + + UserInterface.ShowReportByMonth(report); + } + } + diff --git a/PointOfSale.RyanW84/UserInterface.cs b/PointOfSale.RyanW84/UserInterface.cs new file mode 100644 index 0000000..7ca1735 --- /dev/null +++ b/PointOfSale.RyanW84/UserInterface.cs @@ -0,0 +1,355 @@ +using System.ComponentModel.DataAnnotations; + +using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.EntityFramework.RyanW84.Models.DTOs; +using PointOfSale.EntityFramework.RyanW84.Services; + +using Spectre.Console; + +using static PointOfSale.EntityFramework.RyanW84.Enums; + +namespace PointOfSale.EntityFramework.RyanW84; + +static internal class UserInterface + { + + + //Menu Methods + private static string GetEnumDisplayName(Enum enumValue) //Enums weren't showing their display name, this fixes it + { + var displayAttribute = + enumValue + .GetType() + .GetField(enumValue.ToString()) + .GetCustomAttributes(typeof(DisplayAttribute), false) + .FirstOrDefault() as DisplayAttribute; + + if (displayAttribute == null) + { + Console.WriteLine("No Enum display names found"); + } + + return displayAttribute != null ? displayAttribute.Name : enumValue.ToString(); + } + + internal static void MainMenu() + { + Console.Clear(); + + bool isMenuRunning = true; + + while (isMenuRunning) + { + Console.Clear(); + var usersChoice = AnsiConsole.Prompt( + new SelectionPrompt() + .Title("Welcome to E.P.O.S\nWhat would you like to do?") + .AddChoices(Enum.GetValues(typeof(MainMenuOptions)).Cast()) + .UseConverter(choice => GetEnumDisplayName(choice)) + ); + + switch (usersChoice) + { + case MainMenuOptions.ManageCategories: + CategoriesMenu(); + break; + case MainMenuOptions.ManageProducts: + ProductsMenu(); + break; + case MainMenuOptions.ManagerOrders: + OrdersMenu(); + break; + case MainMenuOptions.GenerateReport: + ReportService.CreateMonthlyReport(); + break; + case MainMenuOptions.Quit: + isMenuRunning = false; + Console.WriteLine("Thank you for using our E.P.O.S App"); + break; + default: + Console.WriteLine("Please enter a correct option"); + Console.ReadKey(); + MainMenu(); + break; + + } + } + } + + internal static void CategoriesMenu() + { + bool isCategoryMenuRunning = true; + + while (isCategoryMenuRunning) + { + Console.Clear(); + var usersChoice = AnsiConsole.Prompt( + new SelectionPrompt() + .Title("Welcome to E.P.O.S\nWhat would you like to do?") + .AddChoices(Enum.GetValues(typeof(CategoryMenu)).Cast()) + .UseConverter(choice => GetEnumDisplayName(choice)) + ); + + switch (usersChoice) + { + case CategoryMenu.AddCategory: + CategoryService.InsertCategory(); + break; + case CategoryMenu.DeleteCategory: + CategoryService.DeleteCategory(); + break; + case CategoryMenu.UpdateCategory: + CategoryService.UpdateCategory(); + break; + case CategoryMenu.ViewCategory: + CategoryService.GetCategory(); + break; + case CategoryMenu.ViewAllCategories: + CategoryService.GetCategories(); + break; + case CategoryMenu.GoBack: + isCategoryMenuRunning = false; + break; + default: + Console.Write("Please choose a valid option (Press Any Key to continue:"); + Console.ReadLine(); + CategoriesMenu(); + break; + } + } + } + + internal static void ProductsMenu() + { + bool isProductMenuRunning = true; + + while (isProductMenuRunning) + { + Console.Clear(); + var usersChoice = AnsiConsole.Prompt( + new SelectionPrompt() + .Title("Welcome to E.P.O.S\nWhat would you like to do?") + .AddChoices(Enum.GetValues(typeof(ProductMenu)).Cast()) + .UseConverter(choice => GetEnumDisplayName(choice)) + ); + + switch (usersChoice) + { + case ProductMenu.AddProduct: + ProductService.InsertProduct(); + break; + case ProductMenu.DeleteProduct: + ProductService.DeleteProduct(); + break; + case ProductMenu.UpdateProduct: + ProductService.UpdateProduct(); + break; + case ProductMenu.ViewProduct: + ProductService.GetProduct(); + break; + case ProductMenu.ViewAllProducts: + ProductService.GetProducts(); + break; + case ProductMenu.GoBack: + isProductMenuRunning = false; + break; + default: + Console.Write("Please choose a valid option (Press Any Key to continue:"); + Console.ReadLine(); + ProductsMenu(); + break; + } + } + } + + internal static void OrdersMenu() + { + bool isOrdersMenuRunning = true; + + while (isOrdersMenuRunning) + { + Console.Clear(); + var usersChoice = AnsiConsole.Prompt( + new SelectionPrompt() + .Title("Welcome to E.P.O.S\nWhat would you like to do?") + .AddChoices(Enum.GetValues(typeof(OrderMenu)).Cast()) + .UseConverter(choice => GetEnumDisplayName(choice)) + ); + + switch (usersChoice) + { + case OrderMenu.AddOrder: + OrderService.InsertOrder(); + break; + case OrderMenu.ViewOrder: + OrderService.GetOrder(); + break; + case OrderMenu.ViewAllOrders: + OrderService.GetOrders(); + break; + case OrderMenu.GoBack: + isOrdersMenuRunning = false; + break; + default: + Console.Write("Please choose a valid option (Press Any Key to continue:"); + Console.ReadLine(); + OrdersMenu(); + break; + } + } + } + + internal static void ShowProduct(Product product) + { + var panel = new Panel($"ID: {product.ProductId} \nName: {product.Name} \nPrice: £{product.Price} \nCategory: {product.Category.Name}"); + panel.Header = new PanelHeader("** Product Info **"); + panel.Padding = new Padding(2, 2, 2, 2); + + AnsiConsole.Write(panel); + Console.WriteLine("Press any key to return to Main Menu"); + Console.ReadLine(); + + } + + static internal void ShowProductTable(List products) + { + var table = new Table(); + table.AddColumn("ID"); + table.AddColumn("Name"); + table.AddColumn("Price £"); + table.AddColumn("Category"); + + foreach (var product in products) + { + table.AddRow( + product.ProductId.ToString(), + product.Name, + product.Price.ToString(), + product.Category.Name + ); + } + + AnsiConsole.Write(table); + + Console.WriteLine("Press any key to continue"); + Console.ReadLine(); + } + + internal static void ShowCategoryTable(List categories) + { + var table = new Table(); + table.AddColumn("ID"); + table.AddColumn("Name"); + + foreach (Category category in categories) + { + table.AddRow( + category.CategoryId.ToString(), + category.Name + ); + } + + AnsiConsole.Write(table); + + Console.WriteLine("Press any key to continue"); + Console.ReadLine(); + } + + internal static void ShowCategory(Category category) + { + + var panel = new Panel($"ID: {category.CategoryId} \nName: {category.Name} \nProduct Count: {category.Products.Count}"); + panel.Header = new PanelHeader($"** {category.Name} **"); + panel.Padding = new Padding(2, 2, 2, 2); + + AnsiConsole.Write(panel); + + ShowProductTable(category.Products); + + Console.WriteLine("Press any key to return to Main Menu"); + Console.ReadLine(); + } + + internal static void ShowOrderTable(List orders) + { + var table = new Table(); + table.AddColumn("ID"); + table.AddColumn("Date"); + table.AddColumn("Count"); + table.AddColumn("Total Price £"); + + foreach (Order order in orders) + { + table.AddRow( + order.OrderId.ToString(), + order.CreatedDate.ToString(), + order.OrderProducts.Sum(x=> x.Quantity).ToString(), + order.TotalPrice.ToString() + ); + } + + AnsiConsole.Write(table); + + Console.WriteLine("Press any key to continue"); + Console.ReadLine(); + } + + internal static void ShowOrder(Order order) + { + + var panel = new Panel($"ID: {order.OrderId} \nDate: {order.CreatedDate} \nProduct Count: {order.OrderProducts.Sum(x=>x.Quantity)}"); + panel.Header = new PanelHeader($"** Order #{order.OrderId} **"); + panel.Padding = new Padding(2, 2, 2, 2); + + AnsiConsole.Write(panel); + } + + internal static void ShowProductForOrderTable(List products) + { + var table = new Table(); + table.AddColumn("ID"); + table.AddColumn("Name"); + table.AddColumn("Category"); + table.AddColumn("Price £"); + table.AddColumn("Quantity"); + table.AddColumn("Total Price £"); + + foreach (var product in products) + { + table.AddRow( + product.Id.ToString(), + product.Name, + product.CategoryName, + product.Price.ToString(), + product.Quantity.ToString(), + product.TotalPrice.ToString()); + } + + AnsiConsole.Write(table); + + Console.WriteLine("Press Any Key to Return to Menu"); + Console.ReadLine(); + Console.Clear(); + } + + internal static void ShowReportByMonth(List report) + { + var table = new Table(); + table.AddColumn("Month"); + table.AddColumn("Total Quantity"); + table.AddColumn("Total Sales £"); + + foreach (var item in report) + { + table.AddRow( + item.Month, + item.TotalQuantity.ToString(), + item.TotalPrice.ToString()); + } + + AnsiConsole.Write(table); + Console.WriteLine("Press any key to continue"); + Console.ReadKey(); //08:30 + } + } + diff --git a/README.md b/README.md deleted file mode 100644 index d9b8713..0000000 --- a/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# CONSOLE.PointOfSale - -A small kebab shop hired the C# Academy team to create a simple app that will serve as point of sale. -Since their budget is only 2$ we've decided to make a Console App. - -The app should have a list with 10 types of kebab and should be user friendly and very fast, since this shop is -very popular and queues can get quite long.