From 1ac62bb7f1861398d870891ad785e2be4ca8fb2b Mon Sep 17 00:00:00 2001 From: RyanW84 Date: Thu, 3 Apr 2025 21:07:57 +0100 Subject: [PATCH 01/10] first commit deleted example files --- KebPOS.sln | 28 - KebPOS/Appsettings.json | 3 - KebPOS/DbContexts/KebabContext.cs | 37 -- KebPOS/KebPOS.csproj | 26 - KebPOS/Kebab.db-shm | Bin 32768 -> 0 bytes KebPOS/Kebab.db-wal | Bin 16512 -> 0 bytes KebPOS/KebabController.cs | 74 --- ...0221127010222_InitialMigration.Designer.cs | 276 ---------- .../20221127010222_InitialMigration.cs | 133 ----- .../20221127063403_orderModels.Designer.cs | 276 ---------- .../Migrations/20221127063403_orderModels.cs | 60 --- ...118234647_OrderIdAutoIncrement.Designer.cs | 276 ---------- .../20230118234647_OrderIdAutoIncrement.cs | 60 --- ...0209113426_RemoveOrdersSeeding.Designer.cs | 219 -------- .../20230209113426_RemoveOrdersSeeding.cs | 234 --------- .../20230303013924_quantity.Designer.cs | 222 -------- KebPOS/Migrations/20230303013924_quantity.cs | 169 ------ .../20240112084734_InitialCreate.Designer.cs | 222 -------- .../20240112084734_InitialCreate.cs | 22 - .../Migrations/KebabContextModelSnapshot.cs | 219 -------- KebPOS/Models/Dtos/ProductDto.cs | 8 - KebPOS/Models/Enums.cs | 43 -- KebPOS/Models/Order.cs | 17 - KebPOS/Models/OrderProduct.cs | 12 - KebPOS/Models/Product.cs | 22 - KebPOS/Program.cs | 6 - KebPOS/Properties/launchSettings.json | 8 - KebPOS/Services/ProductService.cs | 284 ---------- KebPOS/Services/ReportsService.cs | 24 - KebPOS/Services/ShoppingService.cs | 29 -- KebPOS/UserInput.cs | 55 -- KebPOS/UserInterface.cs | 493 ------------------ KebPOS/Validation.cs | 61 --- KebPOSTests/KebPOSTests.csproj | 23 - KebPOSTests/Usings.cs | 1 - KebPOSTests/ValidationTest.cs | 188 ------- README.md | 7 - 37 files changed, 3837 deletions(-) delete mode 100644 KebPOS.sln delete mode 100644 KebPOS/Appsettings.json delete mode 100644 KebPOS/DbContexts/KebabContext.cs delete mode 100644 KebPOS/KebPOS.csproj delete mode 100644 KebPOS/Kebab.db-shm delete mode 100644 KebPOS/Kebab.db-wal delete mode 100644 KebPOS/KebabController.cs delete mode 100644 KebPOS/Migrations/20221127010222_InitialMigration.Designer.cs delete mode 100644 KebPOS/Migrations/20221127010222_InitialMigration.cs delete mode 100644 KebPOS/Migrations/20221127063403_orderModels.Designer.cs delete mode 100644 KebPOS/Migrations/20221127063403_orderModels.cs delete mode 100644 KebPOS/Migrations/20230118234647_OrderIdAutoIncrement.Designer.cs delete mode 100644 KebPOS/Migrations/20230118234647_OrderIdAutoIncrement.cs delete mode 100644 KebPOS/Migrations/20230209113426_RemoveOrdersSeeding.Designer.cs delete mode 100644 KebPOS/Migrations/20230209113426_RemoveOrdersSeeding.cs delete mode 100644 KebPOS/Migrations/20230303013924_quantity.Designer.cs delete mode 100644 KebPOS/Migrations/20230303013924_quantity.cs delete mode 100644 KebPOS/Migrations/20240112084734_InitialCreate.Designer.cs delete mode 100644 KebPOS/Migrations/20240112084734_InitialCreate.cs delete mode 100644 KebPOS/Migrations/KebabContextModelSnapshot.cs delete mode 100644 KebPOS/Models/Dtos/ProductDto.cs delete mode 100644 KebPOS/Models/Enums.cs delete mode 100644 KebPOS/Models/Order.cs delete mode 100644 KebPOS/Models/OrderProduct.cs delete mode 100644 KebPOS/Models/Product.cs delete mode 100644 KebPOS/Program.cs delete mode 100644 KebPOS/Properties/launchSettings.json delete mode 100644 KebPOS/Services/ProductService.cs delete mode 100644 KebPOS/Services/ReportsService.cs delete mode 100644 KebPOS/Services/ShoppingService.cs delete mode 100644 KebPOS/UserInput.cs delete mode 100644 KebPOS/UserInterface.cs delete mode 100644 KebPOS/Validation.cs delete mode 100644 KebPOSTests/KebPOSTests.csproj delete mode 100644 KebPOSTests/Usings.cs delete mode 100644 KebPOSTests/ValidationTest.cs delete mode 100644 README.md 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/KebPOS.csproj b/KebPOS/KebPOS.csproj deleted file mode 100644 index e54d7b7..0000000 --- a/KebPOS/KebPOS.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - Exe - net7.0 - enable - enable - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - Always - - - - diff --git a/KebPOS/Kebab.db-shm b/KebPOS/Kebab.db-shm deleted file mode 100644 index 5bc5c6bfbd4327328590e9c734f74be23b99bfb7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeI)u?fOJ6adhRr=Uc^GKDKxr*Q_WY~UDfBUo8EgH<{Qun-r>2zm(;Qfimtefal3 zcgOL016=XihBl@tvk=y8%~Q^*)xMse>gVAekLBfBZO+YOcUu;J-cL_;5!3n}#CN+d zi_{IXKhO{$K!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2#i=D3zHDLzph6-q|pcvAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U IAn=pG2doDqx&QzG diff --git a/KebPOS/Kebab.db-wal b/KebPOS/Kebab.db-wal deleted file mode 100644 index 476501feeba847d12c08e6abea8bad86c0261777..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16512 zcmeHOO^h5z6&~C1V8^=_QZxtz$Q30hm)(J|j+Z$hdl6w{f)Klr<#3_8yL!4Z)m@{i z?pZfE;N8uS5Jyf(;ey18142UL$SqQC961x{lu)?frvjYd?Me z*IV1Td2{sq=;klCetKj3`X{d48o&G0->$rO`LCnrFTZ~2PnTXB{rU9er^lmb&+O#u zJdfCY5%GxOr@yj{8^Kn>)J$+&vr@C1FT|8>KTQK4WV~ctDOT%>6+$F5Akj=(3^TIe zrC?hMj zb?P~u?oIb+;^uhtsnh+*(bC9L92jYrJIsjG2%E_Qw2FkqO7LQrCgaWy^FxVO&XmYC z7RDeYbFrH$zS5O}JXWVAOCZW(`r>ppJAGz*Ji2wZJvq=ZX9rqw`mjqMJfWDINR!;j z4znjhl%iOp;?}^DB*uw0DtW=ONZ4}M3Z;lqzZSd8mU>w!Zdf7XMZt5yQf;u}V6_7c zB)%}6?d4nJ(PvK&Cf~wR_bR2@|2<1pDU~d1PnlF1kp>q6^3J&|px#^*C07jemsxFP zjL#>6@DtY3UGXU6fI;d4O8C9aS;YF?Op)$rw#$Fk6OnbWkY8JJciai&W`NZ2JH z0FH{+f)wiT2YiqS7nxRM9ctn9Qf82q85w5~mgmH)PE%nBpz2X&q^>NCQLO~TDaE4_ z5P4*EzEt87j8*3xJl>w2e){@&^mzdF6$$e^;)?L?4BXwc!<&G_S-D+`SVDe3lvGaU zZ3R!YhH+>Ng1x{_Aeb8ok!e&aZPq+)&G{G*Cv>}|T~~Qt!&+yvv+rCRkDhz`xydo0 zmpxxJ#bFK2k%f3J$XxnyJ8t<5%504YUgsXezX}V7nYSD~6n1BwjumDFy-Q#Z11r0M zjptPsEbD5X5$dUyiXezdXh&u+gE++{$rc&dVF4^9u!M`lid(u501wo+DD(--@Y`ya zWb2&x$>aBOUM>V%fG1waCy##&vMq@t3G?7a)n1Zr7ER&3f`;Hh#dl`sS3fo$eeUhW z4r zxlJK?d8M_J4iQ@U8;J5XfR9y`K*g}-Idr^~0-29^r>xjbNL?oFlmXt55=g%rY&D_A z`9$I7AaOo<{3B%J6yeC_;annm+Y07DIW_0sb?F5G3ApUtIW4aOm-9pT2Vbf|3>scH zxcJc6Xv!%8e1DTKq%FyTE>e}t_=!*X8PMdt?^E(_1wMvo9UdM~XnpPg?Z-g%{c3Lg z4R`J03c0Pb{*9U><10a8@12)VA@aU^e{!G08+vOTTza90#sU6;fp^palMo(GXV&-x zs{~h0ZrWz>CZ;&X|MB!;tRxa$q-&Oeo+&+2+D7`J5e6k0vRWii;UK2N@@;IYe2Lfu zi}v%0p9|RRbk04tCz?Dzt&r*pjvS1z?^M>*dB<3dsuYGGMK+6Pgc6uQ!tjx8O@UZ7 zs+rNgq`|P9BA*{ZcUzSWE4~l8Zk$zR0j)zsCoSfo9K&Z+k#wU|kQ2tX6{00~FhBtL znj#9a!QTG)H@-blMCrZA>8!TZ2mBLO%6SL6VTJ zk!Fd`xTt4RgjqK1b(#ab^2Xj|6G`D{nuI|)6< z`W6WmF>VMBErn79nF~ZJg)vA|+*_%ut_|Tbdu!`5x#OFYBc!H5a&W5X1Oa9UU=#|e zngD3){zd+f2qj}@_ud*>3mb~M&Ed@WO;LM7&G8y*z}_u&QjrGW_efG7C|+BVVD7 zlg#-XS!~^3XdF?vD3WdzKIGq&jn?8BR7g0iEBdG@=~rSdN**aBH^K!)Hiz^?qp5AU zA|PD=2a=%Q(78Q*advii2}$WKJ9+497jFShTX0bf-|*HZ^tgR1^nyxqPHs;HIqgW@ zbSfvwWIV0b6@A@+a#IL{jUuOHk78N#rhbTFt$7V9R715YUAIaOFQIJ{JT{`OE-FG7 z8&L_+7MG%hPjzI2*we~(1U4>)BS~Wt3M|h9vl3ev?6Unf*JqI~!gc(&oD2h}*9-JM zm!xzb@@~&I`vR|h`P<+B%**dTX!-(|LSKL)8^IL%0)@-?|8ie|p)YU?eSrhC1*(r^ zTOjlWDEEZEK;guX!N3v_)Ms?9=QAfreb`U3x{zQExRfA{l0{Qd{8hrU2KFMukAvw#12 zfscA$;H8&BUm)}a!g+ykULc$o2 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/20240112084734_InitialCreate.cs b/KebPOS/Migrations/20240112084734_InitialCreate.cs deleted file mode 100644 index f005293..0000000 --- a/KebPOS/Migrations/20240112084734_InitialCreate.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace KebPOS.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} 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/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. From da34e3f30ecbaa6bb3b72e2da93b2fe82013d558 Mon Sep 17 00:00:00 2001 From: RyanW84 Date: Thu, 3 Apr 2025 21:10:31 +0100 Subject: [PATCH 02/10] initial setup --- .../PointOfSale.RyanW84.csproj | 14 +++++++++++ PointOfSale.RyanW84/PointOfSale.RyanW84.sln | 25 +++++++++++++++++++ PointOfSale.RyanW84/Program.cs | 1 + .../Properties/launchSettings.json | 8 ++++++ 4 files changed, 48 insertions(+) create mode 100644 PointOfSale.RyanW84/PointOfSale.RyanW84.csproj create mode 100644 PointOfSale.RyanW84/PointOfSale.RyanW84.sln create mode 100644 PointOfSale.RyanW84/Program.cs create mode 100644 PointOfSale.RyanW84/Properties/launchSettings.json diff --git a/PointOfSale.RyanW84/PointOfSale.RyanW84.csproj b/PointOfSale.RyanW84/PointOfSale.RyanW84.csproj new file mode 100644 index 0000000..e2f26fa --- /dev/null +++ b/PointOfSale.RyanW84/PointOfSale.RyanW84.csproj @@ -0,0 +1,14 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + diff --git a/PointOfSale.RyanW84/PointOfSale.RyanW84.sln b/PointOfSale.RyanW84/PointOfSale.RyanW84.sln new file mode 100644 index 0000000..00f42c3 --- /dev/null +++ b/PointOfSale.RyanW84/PointOfSale.RyanW84.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35919.96 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointOfSale.RyanW84", "PointOfSale.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/Program.cs b/PointOfSale.RyanW84/Program.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/PointOfSale.RyanW84/Program.cs @@ -0,0 +1 @@ + \ No newline at end of file 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 From 0bc3008c57706477121e3e9968696a8bdb96f99d Mon Sep 17 00:00:00 2001 From: RyanW84 Date: Fri, 4 Apr 2025 14:12:06 +0100 Subject: [PATCH 03/10] Added menu, DB initiation, Add product and working on viewing products from DB --- PointOfSale.RyanW84/Enums.cs | 20 +++++ ...250404125218_initial-migration.Designer.cs | 47 +++++++++++ .../20250404125218_initial-migration.cs | 37 +++++++++ .../ProductsContextModelSnapshot.cs | 44 +++++++++++ ...PointOfSale.EntityFramework.RyanW84.csproj | 20 +++++ ...> PointOfSale.EntityFramework.RyanW84.sln} | 4 +- .../PointOfSale.RyanW84.csproj | 14 ---- PointOfSale.RyanW84/Product.cs | 13 +++ PointOfSale.RyanW84/ProductController.cs | 52 ++++++++++++ PointOfSale.RyanW84/ProductsContext.cs | 13 +++ PointOfSale.RyanW84/Program.cs | 11 ++- .../Properties/launchSettings.json | 2 +- PointOfSale.RyanW84/UserInterface.cs | 79 +++++++++++++++++++ 13 files changed, 338 insertions(+), 18 deletions(-) create mode 100644 PointOfSale.RyanW84/Enums.cs create mode 100644 PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs create mode 100644 PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.cs create mode 100644 PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs create mode 100644 PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.csproj rename PointOfSale.RyanW84/{PointOfSale.RyanW84.sln => PointOfSale.EntityFramework.RyanW84.sln} (86%) delete mode 100644 PointOfSale.RyanW84/PointOfSale.RyanW84.csproj create mode 100644 PointOfSale.RyanW84/Product.cs create mode 100644 PointOfSale.RyanW84/ProductController.cs create mode 100644 PointOfSale.RyanW84/ProductsContext.cs create mode 100644 PointOfSale.RyanW84/UserInterface.cs diff --git a/PointOfSale.RyanW84/Enums.cs b/PointOfSale.RyanW84/Enums.cs new file mode 100644 index 0000000..0a886f8 --- /dev/null +++ b/PointOfSale.RyanW84/Enums.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; + +namespace PointOfSale.EntityFramework.RyanW84; + +enum MenuOptions + { + [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 = "Quit")] + Quit + } + 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..22cc3e7 --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs @@ -0,0 +1,47 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PointOfSale.EntityFramework.EntityFramework; + +#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("Id") + .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("Id"); + + 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/ProductsContextModelSnapshot.cs b/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs new file mode 100644 index 0000000..bd2fae6 --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs @@ -0,0 +1,44 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PointOfSale.EntityFramework.EntityFramework; + +#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.Product", b => + { + b.Property("Id") + .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("Id"); + + b.ToTable("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.csproj b/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.csproj new file mode 100644 index 0000000..0c1cec1 --- /dev/null +++ b/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.csproj @@ -0,0 +1,20 @@ + + + + Exe + net9.0 + enable + disable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/PointOfSale.RyanW84/PointOfSale.RyanW84.sln b/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.sln similarity index 86% rename from PointOfSale.RyanW84/PointOfSale.RyanW84.sln rename to PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.sln index 00f42c3..f4e2c68 100644 --- a/PointOfSale.RyanW84/PointOfSale.RyanW84.sln +++ b/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.13.35919.96 d17.13 +VisualStudioVersion = 17.13.35919.96 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointOfSale.RyanW84", "PointOfSale.RyanW84.csproj", "{DC9E8356-9FA1-4022-A813-D13E7A944E83}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointOfSale.EntityFramework.RyanW84", "PointOfSale.EntityFramework.RyanW84.csproj", "{DC9E8356-9FA1-4022-A813-D13E7A944E83}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/PointOfSale.RyanW84/PointOfSale.RyanW84.csproj b/PointOfSale.RyanW84/PointOfSale.RyanW84.csproj deleted file mode 100644 index e2f26fa..0000000 --- a/PointOfSale.RyanW84/PointOfSale.RyanW84.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - Exe - net9.0 - enable - enable - - - - - - - diff --git a/PointOfSale.RyanW84/Product.cs b/PointOfSale.RyanW84/Product.cs new file mode 100644 index 0000000..31aad0e --- /dev/null +++ b/PointOfSale.RyanW84/Product.cs @@ -0,0 +1,13 @@ +namespace PointOfSale.EntityFramework.RyanW84; + +internal class Product + { + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public decimal Price { get; set; } = 0; + public int ProductId { get; set; } + + + } + diff --git a/PointOfSale.RyanW84/ProductController.cs b/PointOfSale.RyanW84/ProductController.cs new file mode 100644 index 0000000..9092cbd --- /dev/null +++ b/PointOfSale.RyanW84/ProductController.cs @@ -0,0 +1,52 @@ +using PointOfSale.EntityFramework.EntityFramework; +using PointOfSale.EntityFramework.RyanW84; + +using Spectre.Console; + +namespace PointOfSale.EntityFramework; + +internal class ProductController + { + internal static void AddProduct() + { + var name = AnsiConsole.Ask("Product's name:"); + using var db = new ProductsContext(); + db.Add(new Product { Name = name }); + db.SaveChanges(); + } + + internal static void DeleteProduct() + { + throw new NotImplementedException(); + } + internal static void UpdateProduct() + { + throw new NotImplementedException(); + } + + internal static List GetProducts() + { + using var db = new ProductsContext(); + + var products = db.Products.ToList(); //00:47 + + return products; + } + internal static void ViewProduct() + { + throw new NotImplementedException(); + } + + internal static void ViewAllProducts() + { + throw new NotImplementedException(); + } + + + + + + + + } + diff --git a/PointOfSale.RyanW84/ProductsContext.cs b/PointOfSale.RyanW84/ProductsContext.cs new file mode 100644 index 0000000..c831d40 --- /dev/null +++ b/PointOfSale.RyanW84/ProductsContext.cs @@ -0,0 +1,13 @@ +using Microsoft.EntityFrameworkCore; + +using PointOfSale.EntityFramework.RyanW84; + +namespace PointOfSale.EntityFramework.EntityFramework; + +internal class ProductsContext: DbContext + { + public DbSet Products { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlite($"Data Source = products.db"); + } + diff --git a/PointOfSale.RyanW84/Program.cs b/PointOfSale.RyanW84/Program.cs index 5f28270..28628bd 100644 --- a/PointOfSale.RyanW84/Program.cs +++ b/PointOfSale.RyanW84/Program.cs @@ -1 +1,10 @@ - \ No newline at end of file +using PointOfSale.EntityFramework.RyanW84; + +UserInterface.MainMenu(); + + + + + + + diff --git a/PointOfSale.RyanW84/Properties/launchSettings.json b/PointOfSale.RyanW84/Properties/launchSettings.json index 57cf763..89c9fb0 100644 --- a/PointOfSale.RyanW84/Properties/launchSettings.json +++ b/PointOfSale.RyanW84/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "PointOfSale.RyanW84": { "commandName": "Project", - "workingDirectory": "C:\\Users\\Ryanw\\OneDrive\\Documents\\GitHub\\CONSOLE.PointOfSale\\PointOfSale.RyanW84" + "workingDirectory": @"C:\Users\Ryanw\OneDrive\Documents\GitHub\CONSOLE.PointOfSale\PointOfSale.RyanW84" } } } \ No newline at end of file diff --git a/PointOfSale.RyanW84/UserInterface.cs b/PointOfSale.RyanW84/UserInterface.cs new file mode 100644 index 0000000..06fa75c --- /dev/null +++ b/PointOfSale.RyanW84/UserInterface.cs @@ -0,0 +1,79 @@ +using System.ComponentModel.DataAnnotations; + +using Spectre.Console; + +namespace PointOfSale.EntityFramework.RyanW84; + +internal class UserInterface + { + private static int stackId = 0; + + //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(); + + var isMenuRunning = true; + + var userInterface = new UserInterface(); + + 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(MenuOptions)).Cast()) + .UseConverter(choice => GetEnumDisplayName(choice)) + ); + + switch (usersChoice) + { + case MenuOptions.AddProduct: + ProductController.AddProduct(); + break; + case MenuOptions.DeleteProduct: + ProductController.DeleteProduct(); + break; + case MenuOptions.UpdateProduct: + ProductController.UpdateProduct(); + break; + case MenuOptions.ViewProduct: + ProductController.ViewProduct(); + break; + case MenuOptions.ViewAllProducts: + ProductController.ViewAllProducts(); + break; + case MenuOptions.Quit: + isMenuRunning = false; + Console.WriteLine("Thank you for using our E.P.O.S software\nGoodbye!"); + break; + default: + Console.Write("Please choose a valid option (Press Any Key to continue:"); + Console.ReadLine(); + MainMenu(); + break; + + } + } + } + + + } From dd5903c94a94d2481859144291a90bbe17d5c506 Mon Sep 17 00:00:00 2001 From: RyanW84 Date: Sat, 5 Apr 2025 21:44:52 +0100 Subject: [PATCH 04/10] Added Crud Functionality, Menu Updates, Category table actions --- .../Controllers/CategoryController.cs | 32 +++++ .../Controllers/ProductController.cs | 62 ++++++++++ PointOfSale.RyanW84/Enums.cs | 4 + ...250404125218_initial-migration.Designer.cs | 4 +- .../20250405121706_add-price.Designer.cs | 47 ++++++++ .../Migrations/20250405121706_add-price.cs | 22 ++++ ...20250405201819_Create-Category.Designer.cs | 84 +++++++++++++ .../20250405201819_Create-Category.cs | 110 ++++++++++++++++++ .../ProductsContextModelSnapshot.cs | 49 +++++++- PointOfSale.RyanW84/Models/Category.cs | 19 +++ PointOfSale.RyanW84/Models/Product.cs | 25 ++++ PointOfSale.RyanW84/Product.cs | 13 --- PointOfSale.RyanW84/ProductController.cs | 52 --------- PointOfSale.RyanW84/ProductsContext.cs | 3 +- .../Properties/launchSettings.json | 2 +- .../Services/CategoryService.cs | 46 ++++++++ .../Services/ProductService.cs | 67 +++++++++++ PointOfSale.RyanW84/UserInterface.cs | 83 +++++++++++-- 18 files changed, 637 insertions(+), 87 deletions(-) create mode 100644 PointOfSale.RyanW84/Controllers/CategoryController.cs create mode 100644 PointOfSale.RyanW84/Controllers/ProductController.cs create mode 100644 PointOfSale.RyanW84/Migrations/20250405121706_add-price.Designer.cs create mode 100644 PointOfSale.RyanW84/Migrations/20250405121706_add-price.cs create mode 100644 PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.Designer.cs create mode 100644 PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.cs create mode 100644 PointOfSale.RyanW84/Models/Category.cs create mode 100644 PointOfSale.RyanW84/Models/Product.cs delete mode 100644 PointOfSale.RyanW84/Product.cs delete mode 100644 PointOfSale.RyanW84/ProductController.cs create mode 100644 PointOfSale.RyanW84/Services/CategoryService.cs create mode 100644 PointOfSale.RyanW84/Services/ProductService.cs diff --git a/PointOfSale.RyanW84/Controllers/CategoryController.cs b/PointOfSale.RyanW84/Controllers/CategoryController.cs new file mode 100644 index 0000000..99a1e5e --- /dev/null +++ b/PointOfSale.RyanW84/Controllers/CategoryController.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PointOfSale.EntityFramework.RyanW84.Models; + +using PointOfSale.EntityFramework.EntityFramework; + +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 List GetCategories( ) + { + using var db = new ProductsContext(); + + var categories = db.Categories.ToList(); + + return categories; + } + } + diff --git a/PointOfSale.RyanW84/Controllers/ProductController.cs b/PointOfSale.RyanW84/Controllers/ProductController.cs new file mode 100644 index 0000000..78aacd9 --- /dev/null +++ b/PointOfSale.RyanW84/Controllers/ProductController.cs @@ -0,0 +1,62 @@ +using Microsoft.EntityFrameworkCore; + +using PointOfSale.EntityFramework.EntityFramework; +using PointOfSale.EntityFramework.RyanW84.Models; + +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 index 0a886f8..07f6252 100644 --- a/PointOfSale.RyanW84/Enums.cs +++ b/PointOfSale.RyanW84/Enums.cs @@ -4,6 +4,10 @@ namespace PointOfSale.EntityFramework.RyanW84; enum MenuOptions { + [Display(Name = "Add Category")] + AddCategory, + [Display(Name = "View All Categories")] + ViewAllCategories, [Display(Name = "Add Product")] AddProduct, [Display(Name = "Delete Product")] diff --git a/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs b/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs index 22cc3e7..61f85cd 100644 --- a/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs +++ b/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs @@ -21,7 +21,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Product", b => { - b.Property("Id") + b.Property("ProductId") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); @@ -37,7 +37,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ProductId") .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("ProductId"); b.ToTable("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..5800409 --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/20250405121706_add-price.Designer.cs @@ -0,0 +1,47 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PointOfSale.EntityFramework.EntityFramework; + +#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/PointOfSale.RyanW84/Migrations/20250405121706_add-price.cs b/PointOfSale.RyanW84/Migrations/20250405121706_add-price.cs new file mode 100644 index 0000000..c3db13e --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/20250405121706_add-price.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PointOfSale.EntityFramework.RyanW84.Migrations +{ + /// + public partial class addprice : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(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..5df1518 --- /dev/null +++ b/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.Designer.cs @@ -0,0 +1,84 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PointOfSale.EntityFramework.EntityFramework; + +#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 index bd2fae6..5a42357 100644 --- a/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs +++ b/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs @@ -16,28 +16,65 @@ protected override void BuildModel(ModelBuilder modelBuilder) #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "9.0.3"); - modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Product", b => + modelBuilder.Entity("PointOfSale.EntityFramework.RyanW84.Models.Category", b => { - b.Property("Id") + b.Property("CategoryId") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("Description") + 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.Property("ProductId") - .HasColumnType("INTEGER"); + b.HasKey("ProductId"); - b.HasKey("Id"); + 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..d2346ea --- /dev/null +++ b/PointOfSale.RyanW84/Models/Category.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations; + +using Microsoft.EntityFrameworkCore; + +namespace PointOfSale.EntityFramework.RyanW84.Models; + +[Index(nameof(Name), IsUnique = true)] + +internal class Category + { + [Key] + public int CategoryId { get; set; } + + [Required] + public string Name { get; set; } + + public List Products { get; set; } + } + diff --git a/PointOfSale.RyanW84/Models/Product.cs b/PointOfSale.RyanW84/Models/Product.cs new file mode 100644 index 0000000..7559eca --- /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 + { + [Key] + public int ProductId { get; set; } + + [Required] + public string Name { get; set; } + + [Required] + public decimal Price { get; set; } + + public int CategoryId { get; set; } + + [ForeignKey(nameof(CategoryId))] + public Category Category { get; set; } + } + diff --git a/PointOfSale.RyanW84/Product.cs b/PointOfSale.RyanW84/Product.cs deleted file mode 100644 index 31aad0e..0000000 --- a/PointOfSale.RyanW84/Product.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace PointOfSale.EntityFramework.RyanW84; - -internal class Product - { - public int Id { get; set; } - public string Name { get; set; } - public string Description { get; set; } - public decimal Price { get; set; } = 0; - public int ProductId { get; set; } - - - } - diff --git a/PointOfSale.RyanW84/ProductController.cs b/PointOfSale.RyanW84/ProductController.cs deleted file mode 100644 index 9092cbd..0000000 --- a/PointOfSale.RyanW84/ProductController.cs +++ /dev/null @@ -1,52 +0,0 @@ -using PointOfSale.EntityFramework.EntityFramework; -using PointOfSale.EntityFramework.RyanW84; - -using Spectre.Console; - -namespace PointOfSale.EntityFramework; - -internal class ProductController - { - internal static void AddProduct() - { - var name = AnsiConsole.Ask("Product's name:"); - using var db = new ProductsContext(); - db.Add(new Product { Name = name }); - db.SaveChanges(); - } - - internal static void DeleteProduct() - { - throw new NotImplementedException(); - } - internal static void UpdateProduct() - { - throw new NotImplementedException(); - } - - internal static List GetProducts() - { - using var db = new ProductsContext(); - - var products = db.Products.ToList(); //00:47 - - return products; - } - internal static void ViewProduct() - { - throw new NotImplementedException(); - } - - internal static void ViewAllProducts() - { - throw new NotImplementedException(); - } - - - - - - - - } - diff --git a/PointOfSale.RyanW84/ProductsContext.cs b/PointOfSale.RyanW84/ProductsContext.cs index c831d40..1a5057a 100644 --- a/PointOfSale.RyanW84/ProductsContext.cs +++ b/PointOfSale.RyanW84/ProductsContext.cs @@ -1,12 +1,13 @@ using Microsoft.EntityFrameworkCore; -using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.EntityFramework.RyanW84.Models; namespace PointOfSale.EntityFramework.EntityFramework; internal class ProductsContext: DbContext { public DbSet Products { get; set; } + public DbSet Categories { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlite($"Data Source = products.db"); } diff --git a/PointOfSale.RyanW84/Properties/launchSettings.json b/PointOfSale.RyanW84/Properties/launchSettings.json index 89c9fb0..57cf763 100644 --- a/PointOfSale.RyanW84/Properties/launchSettings.json +++ b/PointOfSale.RyanW84/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "PointOfSale.RyanW84": { "commandName": "Project", - "workingDirectory": @"C:\Users\Ryanw\OneDrive\Documents\GitHub\CONSOLE.PointOfSale\PointOfSale.RyanW84" + "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..d05b57f --- /dev/null +++ b/PointOfSale.RyanW84/Services/CategoryService.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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("Catergory's name:"); + + CategoryController.AddCategory(category); + + } + + internal static void GetCategories() + { + var categories =CategoryController.GetCategories(); + UserInterface.ShowCategoryTable(categories); + + } + + internal static int 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 id = categories.Single(x => x.Name == option).CategoryId; + + + return id; + } + } + diff --git a/PointOfSale.RyanW84/Services/ProductService.cs b/PointOfSale.RyanW84/Services/ProductService.cs new file mode 100644 index 0000000..75488d9 --- /dev/null +++ b/PointOfSale.RyanW84/Services/ProductService.cs @@ -0,0 +1,67 @@ +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(); + + ProductController.AddProduct(product); + } + internal static void DeleteProduct() + { + var product = GetProductOptionInput(); + ProductController.DeleteProduct(product); + } + + internal static void GetProducts() + { + var products = ProductController.GetProducts(); + UserInterface.ShowProductTable(products); + } + + 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; + + + ProductController.UpdateProduct(product); + } + + internal static void GetProduct() + { + var product = GetProductOptionInput(); + UserInterface.ShowProduct(product); + } + + static private 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/UserInterface.cs b/PointOfSale.RyanW84/UserInterface.cs index 06fa75c..8515fea 100644 --- a/PointOfSale.RyanW84/UserInterface.cs +++ b/PointOfSale.RyanW84/UserInterface.cs @@ -1,12 +1,15 @@ using System.ComponentModel.DataAnnotations; +using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.EntityFramework.RyanW84.Services; + using Spectre.Console; namespace PointOfSale.EntityFramework.RyanW84; -internal class UserInterface +static internal class UserInterface { - private static int stackId = 0; + //Menu Methods private static string GetEnumDisplayName(Enum enumValue) //Enums weren't showing their display name, this fixes it @@ -30,13 +33,11 @@ internal static void MainMenu() { Console.Clear(); - var isMenuRunning = true; - - var userInterface = new UserInterface(); + bool isMenuRunning = true; while (isMenuRunning) { - Console.Clear() ; + Console.Clear(); var usersChoice = AnsiConsole.Prompt( new SelectionPrompt() .Title("Welcome to E.P.O.S\nWhat would you like to do?") @@ -46,20 +47,26 @@ internal static void MainMenu() switch (usersChoice) { + case MenuOptions.AddCategory: + CategoryService.InsertCategory(); + break; + case MenuOptions.ViewAllCategories: + CategoryService.GetCategories(); + break; case MenuOptions.AddProduct: - ProductController.AddProduct(); + ProductService.InsertProduct(); break; case MenuOptions.DeleteProduct: - ProductController.DeleteProduct(); + ProductService.DeleteProduct(); break; case MenuOptions.UpdateProduct: - ProductController.UpdateProduct(); + ProductService.UpdateProduct(); break; case MenuOptions.ViewProduct: - ProductController.ViewProduct(); + ProductService.GetProduct(); break; case MenuOptions.ViewAllProducts: - ProductController.ViewAllProducts(); + ProductService.GetProducts(); break; case MenuOptions.Quit: isMenuRunning = false; @@ -75,5 +82,57 @@ internal static void MainMenu() } } + internal static void ShowProduct(Product product) + { + var panel = new Panel($"ID: {product.ProductId} \nName: {product.Name} \nPrice: {product.Price}"); + 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"); + + foreach (var product in products) + { + table.AddRow( + product.ProductId.ToString(), + product.Name, + product.Price.ToString()); + } + + 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(); + } + } + From b08bc8e4a3a9a6b90b02bc1b9623ffec5987c964 Mon Sep 17 00:00:00 2001 From: RyanW84 Date: Sun, 6 Apr 2025 14:10:28 +0100 Subject: [PATCH 05/10] added Delete Category and update Category functionality --- .../Controllers/CategoryController.cs | 18 ++++++++ PointOfSale.RyanW84/Enums.cs | 4 ++ .../Services/CategoryService.cs | 41 ++++++++++--------- .../Services/ProductService.cs | 20 ++++----- PointOfSale.RyanW84/UserInterface.cs | 25 +++++++---- 5 files changed, 70 insertions(+), 38 deletions(-) diff --git a/PointOfSale.RyanW84/Controllers/CategoryController.cs b/PointOfSale.RyanW84/Controllers/CategoryController.cs index 99a1e5e..83a6480 100644 --- a/PointOfSale.RyanW84/Controllers/CategoryController.cs +++ b/PointOfSale.RyanW84/Controllers/CategoryController.cs @@ -20,6 +20,24 @@ internal static void AddCategory(Category 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(); diff --git a/PointOfSale.RyanW84/Enums.cs b/PointOfSale.RyanW84/Enums.cs index 07f6252..b217198 100644 --- a/PointOfSale.RyanW84/Enums.cs +++ b/PointOfSale.RyanW84/Enums.cs @@ -6,8 +6,12 @@ enum MenuOptions { [Display(Name = "Add Category")] AddCategory, + [Display(Name = "Delete Category")] + DeleteCategory, [Display(Name = "View All Categories")] ViewAllCategories, + [Display(Name = "Update Category")] + UpdateCategory, [Display(Name = "Add Product")] AddProduct, [Display(Name = "Delete Product")] diff --git a/PointOfSale.RyanW84/Services/CategoryService.cs b/PointOfSale.RyanW84/Services/CategoryService.cs index d05b57f..633b4a6 100644 --- a/PointOfSale.RyanW84/Services/CategoryService.cs +++ b/PointOfSale.RyanW84/Services/CategoryService.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using PointOfSale.EntityFramework.RyanW84.Controllers; +using PointOfSale.EntityFramework.RyanW84.Controllers; using PointOfSale.EntityFramework.RyanW84.Models; using Spectre.Console; @@ -16,31 +10,40 @@ internal class CategoryService internal static void InsertCategory() { var category = new Category(); - category.Name = AnsiConsole.Ask("Catergory's name:"); + category.Name = AnsiConsole.Ask("Category's name:"); CategoryController.AddCategory(category); } - - internal static void GetCategories() + internal static void DeleteCategory() { - var categories =CategoryController.GetCategories(); - UserInterface.ShowCategoryTable(categories); - + var category = GetCategoryOptionInput(); + CategoryController.DeleteCategory(category); } + internal static void UpdateCategory() + { + var category = GetCategoryOptionInput(); + + category.Name = AnsiConsole.Ask("Category's new name:"); - internal static int GetCategoryOptionInput() + CategoryController.UpdateCategory(category); + } + internal static Category GetCategoryOptionInput() { - var categories - = CategoryController.GetCategories(); + var categories = CategoryController.GetCategories(); var categoriesArray = categories.Select(x => x.Name).ToArray(); var option = AnsiConsole.Prompt(new SelectionPrompt() .Title("Choose Category") .AddChoices(categoriesArray)); - var id = categories.Single(x => x.Name == option).CategoryId; - + var category = categories.Single(x => x.Name == option); - return id; + return category; + } + internal static void GetCategories() + { + var categories = CategoryController.GetCategories(); + UserInterface.ShowCategoryTable(categories); } + } diff --git a/PointOfSale.RyanW84/Services/ProductService.cs b/PointOfSale.RyanW84/Services/ProductService.cs index 75488d9..653d9be 100644 --- a/PointOfSale.RyanW84/Services/ProductService.cs +++ b/PointOfSale.RyanW84/Services/ProductService.cs @@ -13,22 +13,15 @@ internal static void InsertProduct() product.Name = AnsiConsole.Ask("Product's name:"); product.Price = AnsiConsole.Ask("Product's price:"); product.CategoryId = CategoryService. - GetCategoryOptionInput(); + GetCategoryOptionInput().CategoryId; - ProductController.AddProduct(product); + ProductController.AddProduct(product); } internal static void DeleteProduct() { var product = GetProductOptionInput(); ProductController.DeleteProduct(product); } - - internal static void GetProducts() - { - var products = ProductController.GetProducts(); - UserInterface.ShowProductTable(products); - } - internal static void UpdateProduct() { var product = GetProductOptionInput(); @@ -40,17 +33,22 @@ internal static void UpdateProduct() 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; //05:03 ProductController.UpdateProduct(product); } - internal static void GetProduct() { var product = GetProductOptionInput(); UserInterface.ShowProduct(product); } - + internal static void GetProducts() + { + var products = ProductController.GetProducts(); + UserInterface.ShowProductTable(products); + } static private Product GetProductOptionInput() { var products = ProductController.GetProducts(); diff --git a/PointOfSale.RyanW84/UserInterface.cs b/PointOfSale.RyanW84/UserInterface.cs index 8515fea..4c8e134 100644 --- a/PointOfSale.RyanW84/UserInterface.cs +++ b/PointOfSale.RyanW84/UserInterface.cs @@ -50,6 +50,12 @@ internal static void MainMenu() case MenuOptions.AddCategory: CategoryService.InsertCategory(); break; + case MenuOptions.DeleteCategory: + CategoryService.DeleteCategory(); + break; + case MenuOptions.UpdateCategory: + CategoryService.UpdateCategory(); + break; case MenuOptions.ViewAllCategories: CategoryService.GetCategories(); break; @@ -84,7 +90,7 @@ internal static void MainMenu() internal static void ShowProduct(Product product) { - var panel = new Panel($"ID: {product.ProductId} \nName: {product.Name} \nPrice: {product.Price}"); + 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); @@ -99,14 +105,17 @@ static internal void ShowProductTable(List products) var table = new Table(); table.AddColumn("ID"); table.AddColumn("Name"); - table.AddColumn("Price"); + table.AddColumn("Price £"); + table.AddColumn("Category"); foreach (var product in products) { table.AddRow( product.ProductId.ToString(), product.Name, - product.Price.ToString()); + product.Price.ToString(), + product.Category.Name + ); } AnsiConsole.Write(table); @@ -129,10 +138,10 @@ internal static void ShowCategoryTable(List categories) ); } - AnsiConsole.Write(table); + AnsiConsole.Write(table); - Console.WriteLine("Press any key to continue"); - Console.ReadLine(); - } + Console.WriteLine("Press any key to continue"); + Console.ReadLine(); } - + } + From 92c1557e87f38f852c25722a60f4f3c2900ccdbc Mon Sep 17 00:00:00 2001 From: RyanW84 Date: Sun, 6 Apr 2025 21:33:40 +0100 Subject: [PATCH 06/10] Added full categories functionality, Menus separated into three, started creating the Order functionality --- .../Controllers/CategoryController.cs | 28 ++--- PointOfSale.RyanW84/Enums.cs | 64 ++++++---- PointOfSale.RyanW84/Models/Order.cs | 16 +++ PointOfSale.RyanW84/Models/OrderProduct.cs | 12 ++ PointOfSale.RyanW84/Program.cs | 6 - .../Services/CategoryService.cs | 6 +- .../Services/ProductService.cs | 3 +- PointOfSale.RyanW84/UserInterface.cs | 116 +++++++++++++++--- PointOfSale.RyanW84/products.db-shm | Bin 0 -> 32768 bytes PointOfSale.RyanW84/products.db-wal | 0 10 files changed, 189 insertions(+), 62 deletions(-) create mode 100644 PointOfSale.RyanW84/Models/Order.cs create mode 100644 PointOfSale.RyanW84/Models/OrderProduct.cs create mode 100644 PointOfSale.RyanW84/products.db-shm create mode 100644 PointOfSale.RyanW84/products.db-wal diff --git a/PointOfSale.RyanW84/Controllers/CategoryController.cs b/PointOfSale.RyanW84/Controllers/CategoryController.cs index 83a6480..564a480 100644 --- a/PointOfSale.RyanW84/Controllers/CategoryController.cs +++ b/PointOfSale.RyanW84/Controllers/CategoryController.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using PointOfSale.EntityFramework.RyanW84.Models; +using Microsoft.EntityFrameworkCore; using PointOfSale.EntityFramework.EntityFramework; +using PointOfSale.EntityFramework.RyanW84.Models; namespace PointOfSale.EntityFramework.RyanW84.Controllers; @@ -21,15 +17,15 @@ internal static void AddCategory(Category category) } internal static void DeleteCategory(Category category) - { + { using var db = new ProductsContext(); db.Remove(category); - db.SaveChanges(); + db.SaveChanges(); } - internal static void UpdateCategory(Category category) + internal static void UpdateCategory(Category category) { using var db = new ProductsContext(); @@ -38,13 +34,15 @@ internal static void UpdateCategory(Category category) db.SaveChanges(); } - internal static List GetCategories( ) - { - using var db = new ProductsContext(); + internal static List GetCategories() + { + using var db = new ProductsContext(); - var categories = db.Categories.ToList(); + var categories = db.Categories + .Include(x => x.Products) + .ToList(); - return categories; - } + return categories; + } } diff --git a/PointOfSale.RyanW84/Enums.cs b/PointOfSale.RyanW84/Enums.cs index b217198..0269d31 100644 --- a/PointOfSale.RyanW84/Enums.cs +++ b/PointOfSale.RyanW84/Enums.cs @@ -2,27 +2,47 @@ namespace PointOfSale.EntityFramework.RyanW84; -enum MenuOptions +internal class Enums { - [Display(Name = "Add Category")] - AddCategory, - [Display(Name = "Delete Category")] - DeleteCategory, - [Display(Name = "View All Categories")] - ViewAllCategories, - [Display(Name = "Update Category")] - UpdateCategory, - [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 = "Quit")] - Quit - } + internal enum MainMenuOptions + { + [Display(Name = "Manage Categories")] + ManageCategories, + [Display(Name = "Manage Products")] + ManageProducts, + [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 + } + } diff --git a/PointOfSale.RyanW84/Models/Order.cs b/PointOfSale.RyanW84/Models/Order.cs new file mode 100644 index 0000000..46a2454 --- /dev/null +++ b/PointOfSale.RyanW84/Models/Order.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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; } + } + diff --git a/PointOfSale.RyanW84/Models/OrderProduct.cs b/PointOfSale.RyanW84/Models/OrderProduct.cs new file mode 100644 index 0000000..1ee64d0 --- /dev/null +++ b/PointOfSale.RyanW84/Models/OrderProduct.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PointOfSale.EntityFramework.RyanW84.Models; + +internal class OrderProduct //00:58 + { + } + diff --git a/PointOfSale.RyanW84/Program.cs b/PointOfSale.RyanW84/Program.cs index 28628bd..2c3cd9e 100644 --- a/PointOfSale.RyanW84/Program.cs +++ b/PointOfSale.RyanW84/Program.cs @@ -2,9 +2,3 @@ UserInterface.MainMenu(); - - - - - - diff --git a/PointOfSale.RyanW84/Services/CategoryService.cs b/PointOfSale.RyanW84/Services/CategoryService.cs index 633b4a6..b8b587a 100644 --- a/PointOfSale.RyanW84/Services/CategoryService.cs +++ b/PointOfSale.RyanW84/Services/CategoryService.cs @@ -44,6 +44,10 @@ 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/ProductService.cs b/PointOfSale.RyanW84/Services/ProductService.cs index 653d9be..1420db6 100644 --- a/PointOfSale.RyanW84/Services/ProductService.cs +++ b/PointOfSale.RyanW84/Services/ProductService.cs @@ -34,8 +34,7 @@ internal static void UpdateProduct() AnsiConsole.Ask("Product's new price: ") : product.Price; product.Category = AnsiConsole.Confirm("Update Category?") ? - CategoryService.GetCategoryOptionInput() : product.Category; //05:03 - + CategoryService.GetCategoryOptionInput() : product.Category; ProductController.UpdateProduct(product); } diff --git a/PointOfSale.RyanW84/UserInterface.cs b/PointOfSale.RyanW84/UserInterface.cs index 4c8e134..bd12a4b 100644 --- a/PointOfSale.RyanW84/UserInterface.cs +++ b/PointOfSale.RyanW84/UserInterface.cs @@ -5,6 +5,8 @@ using Spectre.Console; +using static PointOfSale.EntityFramework.RyanW84.Enums; + namespace PointOfSale.EntityFramework.RyanW84; static internal class UserInterface @@ -39,51 +41,116 @@ internal static void MainMenu() { Console.Clear(); var usersChoice = AnsiConsole.Prompt( - new SelectionPrompt() + new SelectionPrompt() .Title("Welcome to E.P.O.S\nWhat would you like to do?") - .AddChoices(Enum.GetValues(typeof(MenuOptions)).Cast()) + .AddChoices(Enum.GetValues(typeof(MainMenuOptions)).Cast()) .UseConverter(choice => GetEnumDisplayName(choice)) ); switch (usersChoice) { - case MenuOptions.AddCategory: + case MainMenuOptions.ManageCategories: + CategoriesMenu(); + break; + case MainMenuOptions.ManageProducts: + ProductsMenu(); + 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 MenuOptions.DeleteCategory: + case CategoryMenu.DeleteCategory: CategoryService.DeleteCategory(); break; - case MenuOptions.UpdateCategory: + case CategoryMenu.UpdateCategory: CategoryService.UpdateCategory(); break; - case MenuOptions.ViewAllCategories: + case CategoryMenu.ViewCategory: + CategoryService.GetCategory(); + break; + case CategoryMenu.ViewAllCategories: CategoryService.GetCategories(); break; - case MenuOptions.AddProduct: + 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 MenuOptions.DeleteProduct: + case ProductMenu.DeleteProduct: ProductService.DeleteProduct(); break; - case MenuOptions.UpdateProduct: + case ProductMenu.UpdateProduct: ProductService.UpdateProduct(); break; - case MenuOptions.ViewProduct: + case ProductMenu.ViewProduct: ProductService.GetProduct(); break; - case MenuOptions.ViewAllProducts: + case ProductMenu.ViewAllProducts: ProductService.GetProducts(); break; - case MenuOptions.Quit: - isMenuRunning = false; - Console.WriteLine("Thank you for using our E.P.O.S software\nGoodbye!"); + case ProductMenu.GoBack: + isProductMenuRunning = false; break; default: Console.Write("Please choose a valid option (Press Any Key to continue:"); Console.ReadLine(); - MainMenu(); + ProductsMenu(); break; - } } } @@ -142,6 +209,23 @@ internal static void ShowCategoryTable(List categories) 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(); + + } } diff --git a/PointOfSale.RyanW84/products.db-shm b/PointOfSale.RyanW84/products.db-shm new file mode 100644 index 0000000000000000000000000000000000000000..fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10 GIT binary patch literal 32768 zcmeIuAr62r3 Date: Mon, 7 Apr 2025 14:10:32 +0100 Subject: [PATCH 07/10] Adding order functionality and using fluent API rather than Document Annotation . work in progress --- PointOfSale.RyanW84/Models/Category.cs | 3 -- PointOfSale.RyanW84/Models/Order.cs | 10 ++---- PointOfSale.RyanW84/Models/OrderProduct.cs | 8 ++++- PointOfSale.RyanW84/Models/Product.cs | 8 ++--- PointOfSale.RyanW84/ProductsContext.cs | 41 +++++++++++++++++++++- PointOfSale.RyanW84/Program.cs | 9 ++++- 6 files changed, 62 insertions(+), 17 deletions(-) diff --git a/PointOfSale.RyanW84/Models/Category.cs b/PointOfSale.RyanW84/Models/Category.cs index d2346ea..2a5f180 100644 --- a/PointOfSale.RyanW84/Models/Category.cs +++ b/PointOfSale.RyanW84/Models/Category.cs @@ -4,14 +4,11 @@ namespace PointOfSale.EntityFramework.RyanW84.Models; -[Index(nameof(Name), IsUnique = true)] internal class Category { - [Key] public int CategoryId { get; set; } - [Required] public string Name { get; set; } public List Products { get; set; } diff --git a/PointOfSale.RyanW84/Models/Order.cs b/PointOfSale.RyanW84/Models/Order.cs index 46a2454..33b980a 100644 --- a/PointOfSale.RyanW84/Models/Order.cs +++ b/PointOfSale.RyanW84/Models/Order.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace PointOfSale.EntityFramework.RyanW84.Models; +namespace PointOfSale.EntityFramework.RyanW84.Models; internal class Order { @@ -12,5 +6,7 @@ internal class Order 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 index 1ee64d0..9005434 100644 --- a/PointOfSale.RyanW84/Models/OrderProduct.cs +++ b/PointOfSale.RyanW84/Models/OrderProduct.cs @@ -6,7 +6,13 @@ namespace PointOfSale.EntityFramework.RyanW84.Models; -internal class OrderProduct //00:58 +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 index 7559eca..579aea4 100644 --- a/PointOfSale.RyanW84/Models/Product.cs +++ b/PointOfSale.RyanW84/Models/Product.cs @@ -8,18 +8,18 @@ namespace PointOfSale.EntityFramework.RyanW84.Models; [Index(nameof(Name), IsUnique = true)] internal class Product { - [Key] + public int ProductId { get; set; } - [Required] + public string Name { get; set; } - [Required] public decimal Price { get; set; } public int CategoryId { get; set; } - [ForeignKey(nameof(CategoryId))] public Category Category { get; set; } + + public ICollection OrderProducts { get; set; } } diff --git a/PointOfSale.RyanW84/ProductsContext.cs b/PointOfSale.RyanW84/ProductsContext.cs index 1a5057a..0632155 100644 --- a/PointOfSale.RyanW84/ProductsContext.cs +++ b/PointOfSale.RyanW84/ProductsContext.cs @@ -4,11 +4,50 @@ namespace PointOfSale.EntityFramework.EntityFramework; -internal class ProductsContext: DbContext +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"); + + 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 Category + { + CategoryId = 1, + Name = "Coffee" + }, + new Category + { + CategoryId = 2, + Name = "Juice" + } //05:42 + }); + + } } diff --git a/PointOfSale.RyanW84/Program.cs b/PointOfSale.RyanW84/Program.cs index 2c3cd9e..3d40dba 100644 --- a/PointOfSale.RyanW84/Program.cs +++ b/PointOfSale.RyanW84/Program.cs @@ -1,4 +1,11 @@ -using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.EntityFramework.EntityFramework; +using PointOfSale.EntityFramework.RyanW84; + + +var context = new ProductsContext(); +context.Database.EnsureDeleted(); +context.Database.EnsureCreated(); + UserInterface.MainMenu(); From 32e9d0ad925385978ab9ca32010bebaec11479fd Mon Sep 17 00:00:00 2001 From: RyanW84 Date: Mon, 7 Apr 2025 21:53:20 +0100 Subject: [PATCH 08/10] added full order functionality including viewing singular order, or viewing all orders, ready to move on to reports --- .../Controllers/OrderController.cs | 37 +++++++ PointOfSale.RyanW84/Enums.cs | 14 +++ .../Models/DTOs/ProductForOrderViewDTO.cs | 18 ++++ PointOfSale.RyanW84/ProductsContext.cs | 35 +++++- PointOfSale.RyanW84/Services/OrderService.cs | 98 +++++++++++++++++ .../Services/ProductService.cs | 2 +- PointOfSale.RyanW84/UserInterface.cs | 101 ++++++++++++++++++ PointOfSale.RyanW84/products.db-shm | Bin 32768 -> 0 bytes PointOfSale.RyanW84/products.db-wal | 0 9 files changed, 303 insertions(+), 2 deletions(-) create mode 100644 PointOfSale.RyanW84/Controllers/OrderController.cs create mode 100644 PointOfSale.RyanW84/Models/DTOs/ProductForOrderViewDTO.cs create mode 100644 PointOfSale.RyanW84/Services/OrderService.cs delete mode 100644 PointOfSale.RyanW84/products.db-shm delete mode 100644 PointOfSale.RyanW84/products.db-wal diff --git a/PointOfSale.RyanW84/Controllers/OrderController.cs b/PointOfSale.RyanW84/Controllers/OrderController.cs new file mode 100644 index 0000000..28204d9 --- /dev/null +++ b/PointOfSale.RyanW84/Controllers/OrderController.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Microsoft.EntityFrameworkCore; + +using PointOfSale.EntityFramework.EntityFramework; +using PointOfSale.EntityFramework.RyanW84.Models; + +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/Enums.cs b/PointOfSale.RyanW84/Enums.cs index 0269d31..b83897f 100644 --- a/PointOfSale.RyanW84/Enums.cs +++ b/PointOfSale.RyanW84/Enums.cs @@ -10,6 +10,8 @@ internal enum MainMenuOptions ManageCategories, [Display(Name = "Manage Products")] ManageProducts, + [Display(Name = "Manage Orders")] + ManagerOrders, [Display(Name = "Quit")] Quit } @@ -45,4 +47,16 @@ internal enum ProductMenu [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/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/ProductsContext.cs b/PointOfSale.RyanW84/ProductsContext.cs index 0632155..4f8a551 100644 --- a/PointOfSale.RyanW84/ProductsContext.cs +++ b/PointOfSale.RyanW84/ProductsContext.cs @@ -45,9 +45,42 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { CategoryId = 2, Name = "Juice" - } //05:42 + } }); + modelBuilder.Entity() + .HasData(new List() + { + new Product + { + ProductId = 1, + CategoryId = 1, + Name = "Cappuccino", + Price = 5.0m + }, + new Product + { + ProductId = 2, + CategoryId = 1, + Name = "Latte", + Price =6.0m + }, + new Product + { + ProductId = 3, + CategoryId = 2, + Name = "Orange Juice", + Price = 3.0m + }, + new Product + { + ProductId = 4, + CategoryId = 2, + Name = "Apple Juice", + Price =3.0m + } + }); + } } 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 index 1420db6..56022fb 100644 --- a/PointOfSale.RyanW84/Services/ProductService.cs +++ b/PointOfSale.RyanW84/Services/ProductService.cs @@ -48,7 +48,7 @@ internal static void GetProducts() var products = ProductController.GetProducts(); UserInterface.ShowProductTable(products); } - static private Product GetProductOptionInput() + internal static Product GetProductOptionInput() { var products = ProductController.GetProducts(); var productsArray = products.Select(x => x.Name).ToArray(); diff --git a/PointOfSale.RyanW84/UserInterface.cs b/PointOfSale.RyanW84/UserInterface.cs index bd12a4b..fc66794 100644 --- a/PointOfSale.RyanW84/UserInterface.cs +++ b/PointOfSale.RyanW84/UserInterface.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.EntityFramework.RyanW84.Models.DTOs; using PointOfSale.EntityFramework.RyanW84.Services; using Spectre.Console; @@ -55,6 +56,9 @@ internal static void MainMenu() case MainMenuOptions.ManageProducts: ProductsMenu(); break; + case MainMenuOptions.ManagerOrders: + OrdersMenu(); + break; case MainMenuOptions.Quit: isMenuRunning = false; Console.WriteLine("Thank you for using our E.P.O.S App"); @@ -155,6 +159,43 @@ internal static void ProductsMenu() } } + 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}"); @@ -224,8 +265,68 @@ internal static void ShowCategory(Category category) 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(); } } diff --git a/PointOfSale.RyanW84/products.db-shm b/PointOfSale.RyanW84/products.db-shm deleted file mode 100644 index fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeIuAr62r3 Date: Tue, 8 Apr 2025 14:38:29 +0100 Subject: [PATCH 09/10] reports functionality added --- .../Controllers/CategoryController.cs | 3 +- .../Controllers/OrderController.cs | 33 +- .../Controllers/ProductController.cs | 7 +- PointOfSale.RyanW84/Enums.cs | 2 + ...250404125218_initial-migration.Designer.cs | 3 +- .../20250405121706_add-price.Designer.cs | 3 +- ...20250405201819_Create-Category.Designer.cs | 3 +- .../ProductsContextModelSnapshot.cs | 5 +- .../Models/DTOs/MonthlyReportDTO.cs | 15 + ...PointOfSale.EntityFramework.RyanW84.csproj | 1 + PointOfSale.RyanW84/ProductsContext.cs | 497 ++++++++++++++++-- PointOfSale.RyanW84/Program.cs | 4 +- PointOfSale.RyanW84/Services/ReportService.cs | 29 + PointOfSale.RyanW84/UserInterface.cs | 23 + 14 files changed, 542 insertions(+), 86 deletions(-) create mode 100644 PointOfSale.RyanW84/Models/DTOs/MonthlyReportDTO.cs create mode 100644 PointOfSale.RyanW84/Services/ReportService.cs diff --git a/PointOfSale.RyanW84/Controllers/CategoryController.cs b/PointOfSale.RyanW84/Controllers/CategoryController.cs index 564a480..5839c70 100644 --- a/PointOfSale.RyanW84/Controllers/CategoryController.cs +++ b/PointOfSale.RyanW84/Controllers/CategoryController.cs @@ -1,7 +1,6 @@ using Microsoft.EntityFrameworkCore; - -using PointOfSale.EntityFramework.EntityFramework; using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.RyanW84.RyanW84; namespace PointOfSale.EntityFramework.RyanW84.Controllers; diff --git a/PointOfSale.RyanW84/Controllers/OrderController.cs b/PointOfSale.RyanW84/Controllers/OrderController.cs index 28204d9..972fda8 100644 --- a/PointOfSale.RyanW84/Controllers/OrderController.cs +++ b/PointOfSale.RyanW84/Controllers/OrderController.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using Microsoft.EntityFrameworkCore; - -using PointOfSale.EntityFramework.EntityFramework; +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) + internal static void AddOrder(List orders) { using var db = new ProductsContext(); @@ -22,16 +15,16 @@ internal static void AddOrder(List 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(); + 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; - } + return ordersList; + } } diff --git a/PointOfSale.RyanW84/Controllers/ProductController.cs b/PointOfSale.RyanW84/Controllers/ProductController.cs index 78aacd9..175c6ef 100644 --- a/PointOfSale.RyanW84/Controllers/ProductController.cs +++ b/PointOfSale.RyanW84/Controllers/ProductController.cs @@ -1,7 +1,6 @@ using Microsoft.EntityFrameworkCore; - -using PointOfSale.EntityFramework.EntityFramework; using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.RyanW84.RyanW84; namespace PointOfSale.EntityFramework.RyanW84.Controllers; @@ -35,7 +34,7 @@ internal static Product GetProductById(int id) { using var db = new ProductsContext(); var product = db.Products - .Include(x=>x.Category) + .Include(x => x.Category) .SingleOrDefault(x => x.ProductId == id); return product; @@ -46,7 +45,7 @@ internal static List GetProducts() using var db = new ProductsContext(); var products = db.Products - .Include(x=>x.Category) + .Include(x => x.Category) .ToList(); return products; diff --git a/PointOfSale.RyanW84/Enums.cs b/PointOfSale.RyanW84/Enums.cs index b83897f..969c3b4 100644 --- a/PointOfSale.RyanW84/Enums.cs +++ b/PointOfSale.RyanW84/Enums.cs @@ -12,6 +12,8 @@ internal enum MainMenuOptions ManageProducts, [Display(Name = "Manage Orders")] ManagerOrders, + [Display(Name = "Generate Report")] + GenerateReport, [Display(Name = "Quit")] Quit } diff --git a/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs b/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs index 61f85cd..4becba5 100644 --- a/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs +++ b/PointOfSale.RyanW84/Migrations/20250404125218_initial-migration.Designer.cs @@ -3,7 +3,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using PointOfSale.EntityFramework.EntityFramework; +using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.RyanW84.RyanW84; #nullable disable diff --git a/PointOfSale.RyanW84/Migrations/20250405121706_add-price.Designer.cs b/PointOfSale.RyanW84/Migrations/20250405121706_add-price.Designer.cs index 5800409..a7bce60 100644 --- a/PointOfSale.RyanW84/Migrations/20250405121706_add-price.Designer.cs +++ b/PointOfSale.RyanW84/Migrations/20250405121706_add-price.Designer.cs @@ -3,7 +3,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using PointOfSale.EntityFramework.EntityFramework; +using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.RyanW84.RyanW84; #nullable disable diff --git a/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.Designer.cs b/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.Designer.cs index 5df1518..f0272d2 100644 --- a/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.Designer.cs +++ b/PointOfSale.RyanW84/Migrations/20250405201819_Create-Category.Designer.cs @@ -3,7 +3,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using PointOfSale.EntityFramework.EntityFramework; +using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.RyanW84.RyanW84; #nullable disable diff --git a/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs b/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs index 5a42357..9aba633 100644 --- a/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs +++ b/PointOfSale.RyanW84/Migrations/ProductsContextModelSnapshot.cs @@ -1,8 +1,9 @@ -// + using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using PointOfSale.EntityFramework.EntityFramework; +using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.RyanW84.RyanW84; #nullable disable 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/PointOfSale.EntityFramework.RyanW84.csproj b/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.csproj index 0c1cec1..ee7a2b8 100644 --- a/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.csproj +++ b/PointOfSale.RyanW84/PointOfSale.EntityFramework.RyanW84.csproj @@ -14,6 +14,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/PointOfSale.RyanW84/ProductsContext.cs b/PointOfSale.RyanW84/ProductsContext.cs index 4f8a551..42340a0 100644 --- a/PointOfSale.RyanW84/ProductsContext.cs +++ b/PointOfSale.RyanW84/ProductsContext.cs @@ -1,8 +1,9 @@ using Microsoft.EntityFrameworkCore; - +using Microsoft.Extensions.Logging; using PointOfSale.EntityFramework.RyanW84.Models; +using PointOfSale.EntityFramework.RyanW84; -namespace PointOfSale.EntityFramework.EntityFramework; +namespace PointOfSale.RyanW84.RyanW84; internal class ProductsContext : DbContext { @@ -11,7 +12,23 @@ internal class ProductsContext : DbContext public DbSet Orders { get; set; } public DbSet OrderProducts { get; set; } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlite($"Data Source = products.db"); + 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) { @@ -24,63 +41,437 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasForeignKey(op => op.OrderId); modelBuilder.Entity() - .HasOne(op => op.Product) - .WithMany(o => o.OrderProducts) - .HasForeignKey(op => op.ProductId); + .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); + .HasOne(p => p.Category) + .WithMany(o => o.Products) + .HasForeignKey(p => p.CategoryId); modelBuilder.Entity() - .HasData(new List() + .HasData(new List { - new Category - { - CategoryId = 1, - Name = "Coffee" - }, - new Category - { - CategoryId = 2, - Name = "Juice" - } + 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 Product - { - ProductId = 1, - CategoryId = 1, - Name = "Cappuccino", - Price = 5.0m - }, - new Product - { - ProductId = 2, - CategoryId = 1, - Name = "Latte", - Price =6.0m - }, - new Product - { - ProductId = 3, - CategoryId = 2, - Name = "Orange Juice", - Price = 3.0m - }, - new Product - { - ProductId = 4, - CategoryId = 2, - Name = "Apple Juice", - Price =3.0m - } - }); + .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 index 3d40dba..74c1caf 100644 --- a/PointOfSale.RyanW84/Program.cs +++ b/PointOfSale.RyanW84/Program.cs @@ -1,5 +1,5 @@ -using PointOfSale.EntityFramework.EntityFramework; -using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.EntityFramework.RyanW84; +using PointOfSale.RyanW84.RyanW84; var context = new ProductsContext(); diff --git a/PointOfSale.RyanW84/Services/ReportService.cs b/PointOfSale.RyanW84/Services/ReportService.cs new file mode 100644 index 0000000..196d146 --- /dev/null +++ b/PointOfSale.RyanW84/Services/ReportService.cs @@ -0,0 +1,29 @@ +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 + }) + .Select(grp => new MonthlyReportDTO + { + //Igrouping links elements by Key + Month = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(grp.Key.Month), + 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 index fc66794..7ca1735 100644 --- a/PointOfSale.RyanW84/UserInterface.cs +++ b/PointOfSale.RyanW84/UserInterface.cs @@ -59,6 +59,9 @@ internal static void MainMenu() 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"); @@ -328,5 +331,25 @@ internal static void ShowProductForOrderTable(List produ 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 + } } From 7cffce71f949628cb52a2729cb20a98240509754 Mon Sep 17 00:00:00 2001 From: RyanW84 Date: Tue, 8 Apr 2025 20:29:03 +0100 Subject: [PATCH 10/10] Finished - fixed generate report so it groups by month and year --- PointOfSale.RyanW84/Services/ReportService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PointOfSale.RyanW84/Services/ReportService.cs b/PointOfSale.RyanW84/Services/ReportService.cs index 196d146..6e251ac 100644 --- a/PointOfSale.RyanW84/Services/ReportService.cs +++ b/PointOfSale.RyanW84/Services/ReportService.cs @@ -13,12 +13,13 @@ internal static void CreateMonthlyReport() var report = orders.GroupBy(x => new //Linq creates anonymous object { - x.CreatedDate.Month + x.CreatedDate.Month, + x.CreatedDate.Year }) .Select(grp => new MonthlyReportDTO { //Igrouping links elements by Key - Month = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(grp.Key.Month), + 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();