Browse Source

Menu View, Cart, RUsers & Roles WIP

master
George Williams 4 years ago
parent
commit
79a1289fb9
28 changed files with 1405 additions and 38 deletions
  1. BIN
      .vs/ProRestaurant/DesignTimeBuild/.dtbcache.v2
  2. BIN
      .vs/ProRestaurant/v16/.suo
  3. 24
    1
      ProRestaurant/Classes/CommonFunctions.cs
  4. 3
    7
      ProRestaurant/Classes/Enums.cs
  5. 1
    1
      ProRestaurant/Classes/ImageFormatter.cs
  6. 2
    0
      ProRestaurant/Containers/RestaurantContainer.cs
  7. 3
    3
      ProRestaurant/Controllers/Restaurants/MenuController.cs
  8. 65
    0
      ProRestaurant/Controllers/Restaurants/RestaurantUserController.cs
  9. 487
    0
      ProRestaurant/Migrations/20200703140940_Menu Options Change.Designer.cs
  10. 118
    0
      ProRestaurant/Migrations/20200703140940_Menu Options Change.cs
  11. 489
    0
      ProRestaurant/Migrations/20200706125622_User add password flag.Designer.cs
  12. 23
    0
      ProRestaurant/Migrations/20200706125622_User add password flag.cs
  13. 19
    4
      ProRestaurant/Migrations/DBContextModelSnapshot.cs
  14. 2
    4
      ProRestaurant/Models/Accounts/User.cs
  15. 1
    0
      ProRestaurant/Models/Restaurants/MenuItem.cs
  16. 6
    4
      ProRestaurant/Models/Restaurants/MenuOption.cs
  17. 61
    8
      ProRestaurant/Repository/Restaurants/IMenuRepository.cs
  18. 95
    0
      ProRestaurant/Repository/Restaurants/IRestaurantUserRepository.cs
  19. 2
    3
      ProRestaurant/Repository/Restaurants/MenuOptionRepository.cs
  20. 1
    0
      ProRestaurant/Startup.cs
  21. 1
    1
      ProRestaurant/appsettings.json
  22. BIN
      ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.dll
  23. BIN
      ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.pdb
  24. 1
    1
      ProRestaurant/bin/Debug/netcoreapp2.2/appsettings.json
  25. 1
    1
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csproj.CoreCompileInputs.cache
  26. BIN
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csprojAssemblyReference.cache
  27. BIN
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.dll
  28. BIN
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.pdb

BIN
.vs/ProRestaurant/DesignTimeBuild/.dtbcache.v2 View File


BIN
.vs/ProRestaurant/v16/.suo View File


+ 24
- 1
ProRestaurant/Classes/CommonFunctions.cs View File

@@ -1,4 +1,6 @@
1
-using System;
1
+using Microsoft.AspNetCore.Http;
2
+using System;
3
+using System.Collections;
2 4
 using System.Collections.Generic;
3 5
 using System.Linq;
4 6
 using System.Security.Cryptography;
@@ -20,5 +22,26 @@ namespace ProRestaurant.Classes
20 22
             }
21 23
             return hash;
22 24
         }
25
+
26
+        public static string GenerateRandomPassword()
27
+        {
28
+            string values = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%_";
29
+            char[] chars = values.ToArray();
30
+            ArrayList used = new ArrayList();
31
+
32
+            string password = "";
33
+            while (password.Length < 10)
34
+            {
35
+                Random r = new Random();
36
+                int i = r.Next(0, values.Length);
37
+                if (!used.Contains(chars[i].ToString()))
38
+                {
39
+                    password += chars[i].ToString();
40
+                    used.Add(chars[i].ToString());
41
+                }
42
+            }
43
+
44
+            return password;
45
+        }
23 46
     }
24 47
 }

+ 3
- 7
ProRestaurant/Classes/Enums.cs View File

@@ -1,16 +1,12 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-
6
-namespace ProRestaurant.Classes
1
+namespace ProRestaurant.Classes
7 2
 {
8 3
     public enum SystemRole
9 4
     {
10 5
         SuperAdmin,
11 6
         RestaurantAdmin,
12 7
         RestaurantUser,        
13
-        Customer
8
+        Customer,
9
+        Driver
14 10
     }
15 11
 
16 12
     public enum OptionType

+ 1
- 1
ProRestaurant/Classes/ImageFormatter.cs View File

@@ -59,6 +59,6 @@ namespace ProRestaurant.Classes
59 59
             }
60 60
             else
61 61
                 return "";
62
-        }
62
+        }        
63 63
     }
64 64
 }

+ 2
- 0
ProRestaurant/Containers/RestaurantContainer.cs View File

@@ -40,7 +40,9 @@ namespace ProRestaurant.Containers
40 40
 
41 41
     public class OptionItemContainer
42 42
     {
43
+        public int Id { get; set; }
43 44
         public string Description { get; set; }
45
+        public int Qty { get; set; }
44 46
         public decimal Price { get; set; }        
45 47
     }
46 48
 }

+ 3
- 3
ProRestaurant/Controllers/Restaurants/MenuController.cs View File

@@ -20,10 +20,10 @@ namespace ProRestaurant.Controllers.Restaurants
20 20
             return new OkObjectResult(repo.GetMenu(id));
21 21
         }
22 22
 
23
-        [HttpGet("GetOptions/{menuId}/{categoryId}")]
24
-        public IActionResult GetOptions(int menuId, int categoryId)
23
+        [HttpGet("GetOptions/{menuId}")]
24
+        public IActionResult GetOptions(int menuId)
25 25
         {
26
-            return new OkObjectResult(repo.GetOptions(menuId, categoryId));
26
+            return new OkObjectResult(repo.GetOptions(menuId));
27 27
         }
28 28
     }
29 29
 }

+ 65
- 0
ProRestaurant/Controllers/Restaurants/RestaurantUserController.cs View File

@@ -0,0 +1,65 @@
1
+using Microsoft.AspNetCore.Mvc;
2
+using ProRestaurant.Models.Restaurants;
3
+using ProRestaurant.Repository.Restaurants;
4
+using System.Transactions;
5
+
6
+namespace ProRestaurant.Controllers.Restaurants
7
+{
8
+    [Route("api/[controller]")]
9
+    [ApiController]
10
+    public class RestaurantUserController : ControllerBase
11
+    {
12
+        public readonly IRestaurantUserRepository repo;
13
+
14
+        public RestaurantUserController(IRestaurantUserRepository _repo)
15
+        {
16
+            repo = _repo;
17
+        }
18
+
19
+
20
+        [HttpGet("GetRestaurantUsers/{id}")]
21
+        public IActionResult GetRestaurantUsers(int id)
22
+        {
23
+            return new OkObjectResult(repo.GetUsers(id));
24
+        }
25
+        
26
+        [HttpGet("{id}")]
27
+        public IActionResult Get(int id)
28
+        {
29
+            return new OkObjectResult(repo.GetRestaurantUser(id));
30
+        }
31
+        
32
+        [HttpPost]
33
+        public IActionResult Post([FromBody] RestaurantUser value)
34
+        {
35
+            using (var scope = new TransactionScope())
36
+            {
37
+                repo.InsertUser(value);
38
+                scope.Complete();
39
+                return CreatedAtAction(nameof(Get), new { id = value.Id }, value);
40
+            }
41
+        }
42
+        
43
+        [HttpPut]
44
+        public IActionResult Put([FromBody] RestaurantUser value)
45
+        {
46
+            if (value != null)
47
+            {
48
+                using (var scope = new TransactionScope())
49
+                {
50
+                    repo.UpdateUser(value);
51
+                    scope.Complete();
52
+                    return new OkResult();
53
+                }
54
+            }
55
+            return new NoContentResult();
56
+        }
57
+        
58
+        [HttpDelete("{id}")]
59
+        public IActionResult Delete(int id)
60
+        {
61
+            repo.RemoveUser(id);
62
+            return new OkResult();
63
+        }
64
+    }
65
+}

+ 487
- 0
ProRestaurant/Migrations/20200703140940_Menu Options Change.Designer.cs View File

@@ -0,0 +1,487 @@
1
+// <auto-generated />
2
+using System;
3
+using Microsoft.EntityFrameworkCore;
4
+using Microsoft.EntityFrameworkCore.Infrastructure;
5
+using Microsoft.EntityFrameworkCore.Metadata;
6
+using Microsoft.EntityFrameworkCore.Migrations;
7
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8
+using ProRestaurant.DBContexts;
9
+
10
+namespace ProRestaurant.Migrations
11
+{
12
+    [DbContext(typeof(DBContext))]
13
+    [Migration("20200703140940_Menu Options Change")]
14
+    partial class MenuOptionsChange
15
+    {
16
+        protected override void BuildTargetModel(ModelBuilder modelBuilder)
17
+        {
18
+#pragma warning disable 612, 618
19
+            modelBuilder
20
+                .HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
21
+                .HasAnnotation("Relational:MaxIdentifierLength", 128)
22
+                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
23
+
24
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
25
+                {
26
+                    b.Property<int>("Id")
27
+                        .ValueGeneratedOnAdd()
28
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
29
+
30
+                    b.Property<DateTime>("Created");
31
+
32
+                    b.Property<bool>("IsDeleted");
33
+
34
+                    b.Property<DateTime>("Modified");
35
+
36
+                    b.Property<string>("ModifiedBy");
37
+
38
+                    b.Property<string>("Photo");
39
+
40
+                    b.Property<string>("RegistrationNumber");
41
+
42
+                    b.Property<int>("UserId");
43
+
44
+                    b.HasKey("Id");
45
+
46
+                    b.HasIndex("UserId")
47
+                        .IsUnique();
48
+
49
+                    b.ToTable("DriverDetails");
50
+                });
51
+
52
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.User", b =>
53
+                {
54
+                    b.Property<int>("Id")
55
+                        .ValueGeneratedOnAdd()
56
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
57
+
58
+                    b.Property<string>("Cellphone");
59
+
60
+                    b.Property<DateTime>("Created");
61
+
62
+                    b.Property<string>("EmailAddress");
63
+
64
+                    b.Property<string>("FirstName");
65
+
66
+                    b.Property<bool>("IsDeleted");
67
+
68
+                    b.Property<DateTime>("Modified");
69
+
70
+                    b.Property<string>("ModifiedBy");
71
+
72
+                    b.Property<string>("Password");
73
+
74
+                    b.Property<string>("Surname");
75
+
76
+                    b.Property<int>("SystemRole");
77
+
78
+                    b.HasKey("Id");
79
+
80
+                    b.ToTable("Users");
81
+                });
82
+
83
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
84
+                {
85
+                    b.Property<int>("Id")
86
+                        .ValueGeneratedOnAdd()
87
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
88
+
89
+                    b.Property<string>("City");
90
+
91
+                    b.Property<string>("ComplexName");
92
+
93
+                    b.Property<string>("Country");
94
+
95
+                    b.Property<DateTime>("Created");
96
+
97
+                    b.Property<string>("GoogleMapUrl");
98
+
99
+                    b.Property<bool>("IsComplex");
100
+
101
+                    b.Property<bool>("IsDefault");
102
+
103
+                    b.Property<bool>("IsDeleted");
104
+
105
+                    b.Property<decimal>("Latitude");
106
+
107
+                    b.Property<decimal>("Longitude");
108
+
109
+                    b.Property<DateTime>("Modified");
110
+
111
+                    b.Property<string>("ModifiedBy");
112
+
113
+                    b.Property<string>("PostalCode");
114
+
115
+                    b.Property<string>("Province");
116
+
117
+                    b.Property<string>("StreetName");
118
+
119
+                    b.Property<string>("StreetNumber");
120
+
121
+                    b.Property<string>("Suburb");
122
+
123
+                    b.Property<string>("UnitNumber");
124
+
125
+                    b.Property<int>("UserId");
126
+
127
+                    b.HasKey("Id");
128
+
129
+                    b.HasIndex("UserId");
130
+
131
+                    b.ToTable("UserAddresses");
132
+                });
133
+
134
+            modelBuilder.Entity("ProRestaurant.Models.Misc.Locations", b =>
135
+                {
136
+                    b.Property<int>("Id")
137
+                        .ValueGeneratedOnAdd()
138
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
139
+
140
+                    b.Property<string>("CategoryStore");
141
+
142
+                    b.Property<string>("ImageStore");
143
+
144
+                    b.HasKey("Id");
145
+
146
+                    b.ToTable("Locations");
147
+                });
148
+
149
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
150
+                {
151
+                    b.Property<int>("Id")
152
+                        .ValueGeneratedOnAdd()
153
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
154
+
155
+                    b.Property<DateTime>("Created");
156
+
157
+                    b.Property<string>("Description");
158
+
159
+                    b.Property<bool>("IsDeleted");
160
+
161
+                    b.Property<DateTime>("Modified");
162
+
163
+                    b.Property<string>("ModifiedBy");
164
+
165
+                    b.Property<int>("RestaurantId");
166
+
167
+                    b.HasKey("Id");
168
+
169
+                    b.HasIndex("RestaurantId");
170
+
171
+                    b.ToTable("MenuCategories");
172
+                });
173
+
174
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
175
+                {
176
+                    b.Property<int>("Id")
177
+                        .ValueGeneratedOnAdd()
178
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
179
+
180
+                    b.Property<int>("CategoryId");
181
+
182
+                    b.Property<DateTime>("Created");
183
+
184
+                    b.Property<string>("Description");
185
+
186
+                    b.Property<string>("Image");
187
+
188
+                    b.Property<bool>("IsDeleted");
189
+
190
+                    b.Property<DateTime>("Modified");
191
+
192
+                    b.Property<string>("ModifiedBy");
193
+
194
+                    b.Property<string>("Name");
195
+
196
+                    b.Property<bool>("OutOfStock");
197
+
198
+                    b.Property<bool>("OverrideOptions");
199
+
200
+                    b.Property<decimal>("Price");
201
+
202
+                    b.Property<int>("RestaurantId");
203
+
204
+                    b.HasKey("Id");
205
+
206
+                    b.HasIndex("RestaurantId");
207
+
208
+                    b.ToTable("MenuItems");
209
+                });
210
+
211
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
212
+                {
213
+                    b.Property<int>("Id")
214
+                        .ValueGeneratedOnAdd()
215
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
216
+
217
+                    b.Property<int>("CategoryId");
218
+
219
+                    b.Property<DateTime>("Created");
220
+
221
+                    b.Property<string>("Description");
222
+
223
+                    b.Property<bool>("IsBasePrice");
224
+
225
+                    b.Property<bool>("IsDeleted");
226
+
227
+                    b.Property<int?>("MenuCategoryId");
228
+
229
+                    b.Property<int>("MenuItemId");
230
+
231
+                    b.Property<DateTime>("Modified");
232
+
233
+                    b.Property<string>("ModifiedBy");
234
+
235
+                    b.Property<int>("OptionLimit");
236
+
237
+                    b.Property<int>("OptionType");
238
+
239
+                    b.Property<int>("Rank");
240
+
241
+                    b.Property<int>("RestaurantId");
242
+
243
+                    b.HasKey("Id");
244
+
245
+                    b.HasIndex("MenuCategoryId");
246
+
247
+                    b.HasIndex("RestaurantId");
248
+
249
+                    b.ToTable("MenuOptions");
250
+                });
251
+
252
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
253
+                {
254
+                    b.Property<int>("Id")
255
+                        .ValueGeneratedOnAdd()
256
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
257
+
258
+                    b.Property<DateTime>("Created");
259
+
260
+                    b.Property<string>("Description");
261
+
262
+                    b.Property<bool>("IsDeleted");
263
+
264
+                    b.Property<int?>("MenuOptionId");
265
+
266
+                    b.Property<DateTime>("Modified");
267
+
268
+                    b.Property<string>("ModifiedBy");
269
+
270
+                    b.Property<decimal>("Price");
271
+
272
+                    b.Property<int>("Rank");
273
+
274
+                    b.HasKey("Id");
275
+
276
+                    b.HasIndex("MenuOptionId");
277
+
278
+                    b.ToTable("MenuOptionItems");
279
+                });
280
+
281
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
282
+                {
283
+                    b.Property<int>("Id")
284
+                        .ValueGeneratedOnAdd()
285
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
286
+
287
+                    b.Property<string>("Categories");
288
+
289
+                    b.Property<string>("City");
290
+
291
+                    b.Property<string>("Country");
292
+
293
+                    b.Property<DateTime>("Created");
294
+
295
+                    b.Property<decimal>("DeliveryFee");
296
+
297
+                    b.Property<decimal>("DeliveryRadius");
298
+
299
+                    b.Property<string>("DeliveryTime");
300
+
301
+                    b.Property<string>("GoogleMapUrl");
302
+
303
+                    b.Property<bool>("IsDeleted");
304
+
305
+                    b.Property<decimal>("Latitude");
306
+
307
+                    b.Property<string>("Logo");
308
+
309
+                    b.Property<decimal>("Longitude");
310
+
311
+                    b.Property<string>("MethodsOfPayment");
312
+
313
+                    b.Property<DateTime>("Modified");
314
+
315
+                    b.Property<string>("ModifiedBy");
316
+
317
+                    b.Property<string>("Name");
318
+
319
+                    b.Property<string>("PostalCode");
320
+
321
+                    b.Property<string>("Province");
322
+
323
+                    b.Property<string>("ShopNumber");
324
+
325
+                    b.Property<string>("ShoppingCentre");
326
+
327
+                    b.Property<string>("StreetName");
328
+
329
+                    b.Property<string>("StreetNumber");
330
+
331
+                    b.Property<string>("Suburb");
332
+
333
+                    b.HasKey("Id");
334
+
335
+                    b.ToTable("Restaurants");
336
+                });
337
+
338
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantCategory", b =>
339
+                {
340
+                    b.Property<int>("Id")
341
+                        .ValueGeneratedOnAdd()
342
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
343
+
344
+                    b.Property<string>("Description");
345
+
346
+                    b.Property<string>("Image");
347
+
348
+                    b.HasKey("Id");
349
+
350
+                    b.ToTable("RestaurantCategories");
351
+                });
352
+
353
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
354
+                {
355
+                    b.Property<int>("Id")
356
+                        .ValueGeneratedOnAdd()
357
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
358
+
359
+                    b.Property<DateTime>("Created");
360
+
361
+                    b.Property<bool>("IsDeleted");
362
+
363
+                    b.Property<DateTime>("Modified");
364
+
365
+                    b.Property<string>("ModifiedBy");
366
+
367
+                    b.Property<int>("RestaurantId");
368
+
369
+                    b.Property<int>("UserId");
370
+
371
+                    b.HasKey("Id");
372
+
373
+                    b.HasIndex("RestaurantId");
374
+
375
+                    b.HasIndex("UserId");
376
+
377
+                    b.ToTable("RestaurantUsers");
378
+                });
379
+
380
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
381
+                {
382
+                    b.Property<int>("Id")
383
+                        .ValueGeneratedOnAdd()
384
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
385
+
386
+                    b.Property<bool>("Closed");
387
+
388
+                    b.Property<DateTime>("ClosingTime");
389
+
390
+                    b.Property<DateTime>("Created");
391
+
392
+                    b.Property<string>("Description");
393
+
394
+                    b.Property<bool>("IsDeleted");
395
+
396
+                    b.Property<DateTime>("Modified");
397
+
398
+                    b.Property<string>("ModifiedBy");
399
+
400
+                    b.Property<bool>("Opened24H");
401
+
402
+                    b.Property<DateTime>("OpeningTime");
403
+
404
+                    b.Property<int>("RestaurantId");
405
+
406
+                    b.HasKey("Id");
407
+
408
+                    b.HasIndex("RestaurantId");
409
+
410
+                    b.ToTable("TradingHours");
411
+                });
412
+
413
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
414
+                {
415
+                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
416
+                        .WithOne("DriverDetails")
417
+                        .HasForeignKey("ProRestaurant.Models.Accounts.DriverDetail", "UserId")
418
+                        .OnDelete(DeleteBehavior.Cascade);
419
+                });
420
+
421
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
422
+                {
423
+                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
424
+                        .WithMany("Addresses")
425
+                        .HasForeignKey("UserId")
426
+                        .OnDelete(DeleteBehavior.Cascade);
427
+                });
428
+
429
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
430
+                {
431
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
432
+                        .WithMany()
433
+                        .HasForeignKey("RestaurantId")
434
+                        .OnDelete(DeleteBehavior.Cascade);
435
+                });
436
+
437
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
438
+                {
439
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
440
+                        .WithMany()
441
+                        .HasForeignKey("RestaurantId")
442
+                        .OnDelete(DeleteBehavior.Cascade);
443
+                });
444
+
445
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
446
+                {
447
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuCategory")
448
+                        .WithMany("Options")
449
+                        .HasForeignKey("MenuCategoryId");
450
+
451
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
452
+                        .WithMany()
453
+                        .HasForeignKey("RestaurantId")
454
+                        .OnDelete(DeleteBehavior.Cascade);
455
+                });
456
+
457
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
458
+                {
459
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuOption", "MenuOption")
460
+                        .WithMany("Options")
461
+                        .HasForeignKey("MenuOptionId");
462
+                });
463
+
464
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
465
+                {
466
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
467
+                        .WithMany("Users")
468
+                        .HasForeignKey("RestaurantId")
469
+                        .OnDelete(DeleteBehavior.Cascade);
470
+
471
+                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
472
+                        .WithMany()
473
+                        .HasForeignKey("UserId")
474
+                        .OnDelete(DeleteBehavior.Cascade);
475
+                });
476
+
477
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
478
+                {
479
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
480
+                        .WithMany("TradingHours")
481
+                        .HasForeignKey("RestaurantId")
482
+                        .OnDelete(DeleteBehavior.Cascade);
483
+                });
484
+#pragma warning restore 612, 618
485
+        }
486
+    }
487
+}

+ 118
- 0
ProRestaurant/Migrations/20200703140940_Menu Options Change.cs View File

@@ -0,0 +1,118 @@
1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace ProRestaurant.Migrations
4
+{
5
+    public partial class MenuOptionsChange : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.DropForeignKey(
10
+                name: "FK_MenuOptions_MenuCategories_CategoryId",
11
+                table: "MenuOptions");
12
+
13
+            migrationBuilder.DropIndex(
14
+                name: "IX_MenuOptions_CategoryId",
15
+                table: "MenuOptions");
16
+
17
+            migrationBuilder.AlterColumn<int>(
18
+                name: "CategoryId",
19
+                table: "MenuOptions",
20
+                nullable: false,
21
+                oldClrType: typeof(int),
22
+                oldNullable: true);
23
+
24
+            migrationBuilder.AddColumn<int>(
25
+                name: "MenuCategoryId",
26
+                table: "MenuOptions",
27
+                nullable: true);
28
+
29
+            migrationBuilder.AddColumn<int>(
30
+                name: "RestaurantId",
31
+                table: "MenuOptions",
32
+                nullable: false,
33
+                defaultValue: 0);
34
+
35
+            migrationBuilder.AddColumn<bool>(
36
+                name: "OutOfStock",
37
+                table: "MenuItems",
38
+                nullable: false,
39
+                defaultValue: false);
40
+
41
+            migrationBuilder.CreateIndex(
42
+                name: "IX_MenuOptions_MenuCategoryId",
43
+                table: "MenuOptions",
44
+                column: "MenuCategoryId");
45
+
46
+            migrationBuilder.CreateIndex(
47
+                name: "IX_MenuOptions_RestaurantId",
48
+                table: "MenuOptions",
49
+                column: "RestaurantId");
50
+
51
+            migrationBuilder.AddForeignKey(
52
+                name: "FK_MenuOptions_MenuCategories_MenuCategoryId",
53
+                table: "MenuOptions",
54
+                column: "MenuCategoryId",
55
+                principalTable: "MenuCategories",
56
+                principalColumn: "Id",
57
+                onDelete: ReferentialAction.Restrict);
58
+
59
+            migrationBuilder.AddForeignKey(
60
+                name: "FK_MenuOptions_Restaurants_RestaurantId",
61
+                table: "MenuOptions",
62
+                column: "RestaurantId",
63
+                principalTable: "Restaurants",
64
+                principalColumn: "Id",
65
+                onDelete: ReferentialAction.Cascade);
66
+        }
67
+
68
+        protected override void Down(MigrationBuilder migrationBuilder)
69
+        {
70
+            migrationBuilder.DropForeignKey(
71
+                name: "FK_MenuOptions_MenuCategories_MenuCategoryId",
72
+                table: "MenuOptions");
73
+
74
+            migrationBuilder.DropForeignKey(
75
+                name: "FK_MenuOptions_Restaurants_RestaurantId",
76
+                table: "MenuOptions");
77
+
78
+            migrationBuilder.DropIndex(
79
+                name: "IX_MenuOptions_MenuCategoryId",
80
+                table: "MenuOptions");
81
+
82
+            migrationBuilder.DropIndex(
83
+                name: "IX_MenuOptions_RestaurantId",
84
+                table: "MenuOptions");
85
+
86
+            migrationBuilder.DropColumn(
87
+                name: "MenuCategoryId",
88
+                table: "MenuOptions");
89
+
90
+            migrationBuilder.DropColumn(
91
+                name: "RestaurantId",
92
+                table: "MenuOptions");
93
+
94
+            migrationBuilder.DropColumn(
95
+                name: "OutOfStock",
96
+                table: "MenuItems");
97
+
98
+            migrationBuilder.AlterColumn<int>(
99
+                name: "CategoryId",
100
+                table: "MenuOptions",
101
+                nullable: true,
102
+                oldClrType: typeof(int));
103
+
104
+            migrationBuilder.CreateIndex(
105
+                name: "IX_MenuOptions_CategoryId",
106
+                table: "MenuOptions",
107
+                column: "CategoryId");
108
+
109
+            migrationBuilder.AddForeignKey(
110
+                name: "FK_MenuOptions_MenuCategories_CategoryId",
111
+                table: "MenuOptions",
112
+                column: "CategoryId",
113
+                principalTable: "MenuCategories",
114
+                principalColumn: "Id",
115
+                onDelete: ReferentialAction.Restrict);
116
+        }
117
+    }
118
+}

+ 489
- 0
ProRestaurant/Migrations/20200706125622_User add password flag.Designer.cs View File

@@ -0,0 +1,489 @@
1
+// <auto-generated />
2
+using System;
3
+using Microsoft.EntityFrameworkCore;
4
+using Microsoft.EntityFrameworkCore.Infrastructure;
5
+using Microsoft.EntityFrameworkCore.Metadata;
6
+using Microsoft.EntityFrameworkCore.Migrations;
7
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8
+using ProRestaurant.DBContexts;
9
+
10
+namespace ProRestaurant.Migrations
11
+{
12
+    [DbContext(typeof(DBContext))]
13
+    [Migration("20200706125622_User add password flag")]
14
+    partial class Useraddpasswordflag
15
+    {
16
+        protected override void BuildTargetModel(ModelBuilder modelBuilder)
17
+        {
18
+#pragma warning disable 612, 618
19
+            modelBuilder
20
+                .HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
21
+                .HasAnnotation("Relational:MaxIdentifierLength", 128)
22
+                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
23
+
24
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
25
+                {
26
+                    b.Property<int>("Id")
27
+                        .ValueGeneratedOnAdd()
28
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
29
+
30
+                    b.Property<DateTime>("Created");
31
+
32
+                    b.Property<bool>("IsDeleted");
33
+
34
+                    b.Property<DateTime>("Modified");
35
+
36
+                    b.Property<string>("ModifiedBy");
37
+
38
+                    b.Property<string>("Photo");
39
+
40
+                    b.Property<string>("RegistrationNumber");
41
+
42
+                    b.Property<int>("UserId");
43
+
44
+                    b.HasKey("Id");
45
+
46
+                    b.HasIndex("UserId")
47
+                        .IsUnique();
48
+
49
+                    b.ToTable("DriverDetails");
50
+                });
51
+
52
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.User", b =>
53
+                {
54
+                    b.Property<int>("Id")
55
+                        .ValueGeneratedOnAdd()
56
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
57
+
58
+                    b.Property<string>("Cellphone");
59
+
60
+                    b.Property<bool>("ChangePassword");
61
+
62
+                    b.Property<DateTime>("Created");
63
+
64
+                    b.Property<string>("EmailAddress");
65
+
66
+                    b.Property<string>("FirstName");
67
+
68
+                    b.Property<bool>("IsDeleted");
69
+
70
+                    b.Property<DateTime>("Modified");
71
+
72
+                    b.Property<string>("ModifiedBy");
73
+
74
+                    b.Property<string>("Password");
75
+
76
+                    b.Property<string>("Surname");
77
+
78
+                    b.Property<int>("SystemRole");
79
+
80
+                    b.HasKey("Id");
81
+
82
+                    b.ToTable("Users");
83
+                });
84
+
85
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
86
+                {
87
+                    b.Property<int>("Id")
88
+                        .ValueGeneratedOnAdd()
89
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
90
+
91
+                    b.Property<string>("City");
92
+
93
+                    b.Property<string>("ComplexName");
94
+
95
+                    b.Property<string>("Country");
96
+
97
+                    b.Property<DateTime>("Created");
98
+
99
+                    b.Property<string>("GoogleMapUrl");
100
+
101
+                    b.Property<bool>("IsComplex");
102
+
103
+                    b.Property<bool>("IsDefault");
104
+
105
+                    b.Property<bool>("IsDeleted");
106
+
107
+                    b.Property<decimal>("Latitude");
108
+
109
+                    b.Property<decimal>("Longitude");
110
+
111
+                    b.Property<DateTime>("Modified");
112
+
113
+                    b.Property<string>("ModifiedBy");
114
+
115
+                    b.Property<string>("PostalCode");
116
+
117
+                    b.Property<string>("Province");
118
+
119
+                    b.Property<string>("StreetName");
120
+
121
+                    b.Property<string>("StreetNumber");
122
+
123
+                    b.Property<string>("Suburb");
124
+
125
+                    b.Property<string>("UnitNumber");
126
+
127
+                    b.Property<int>("UserId");
128
+
129
+                    b.HasKey("Id");
130
+
131
+                    b.HasIndex("UserId");
132
+
133
+                    b.ToTable("UserAddresses");
134
+                });
135
+
136
+            modelBuilder.Entity("ProRestaurant.Models.Misc.Locations", b =>
137
+                {
138
+                    b.Property<int>("Id")
139
+                        .ValueGeneratedOnAdd()
140
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
141
+
142
+                    b.Property<string>("CategoryStore");
143
+
144
+                    b.Property<string>("ImageStore");
145
+
146
+                    b.HasKey("Id");
147
+
148
+                    b.ToTable("Locations");
149
+                });
150
+
151
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
152
+                {
153
+                    b.Property<int>("Id")
154
+                        .ValueGeneratedOnAdd()
155
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
156
+
157
+                    b.Property<DateTime>("Created");
158
+
159
+                    b.Property<string>("Description");
160
+
161
+                    b.Property<bool>("IsDeleted");
162
+
163
+                    b.Property<DateTime>("Modified");
164
+
165
+                    b.Property<string>("ModifiedBy");
166
+
167
+                    b.Property<int>("RestaurantId");
168
+
169
+                    b.HasKey("Id");
170
+
171
+                    b.HasIndex("RestaurantId");
172
+
173
+                    b.ToTable("MenuCategories");
174
+                });
175
+
176
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
177
+                {
178
+                    b.Property<int>("Id")
179
+                        .ValueGeneratedOnAdd()
180
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
181
+
182
+                    b.Property<int>("CategoryId");
183
+
184
+                    b.Property<DateTime>("Created");
185
+
186
+                    b.Property<string>("Description");
187
+
188
+                    b.Property<string>("Image");
189
+
190
+                    b.Property<bool>("IsDeleted");
191
+
192
+                    b.Property<DateTime>("Modified");
193
+
194
+                    b.Property<string>("ModifiedBy");
195
+
196
+                    b.Property<string>("Name");
197
+
198
+                    b.Property<bool>("OutOfStock");
199
+
200
+                    b.Property<bool>("OverrideOptions");
201
+
202
+                    b.Property<decimal>("Price");
203
+
204
+                    b.Property<int>("RestaurantId");
205
+
206
+                    b.HasKey("Id");
207
+
208
+                    b.HasIndex("RestaurantId");
209
+
210
+                    b.ToTable("MenuItems");
211
+                });
212
+
213
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
214
+                {
215
+                    b.Property<int>("Id")
216
+                        .ValueGeneratedOnAdd()
217
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
218
+
219
+                    b.Property<int>("CategoryId");
220
+
221
+                    b.Property<DateTime>("Created");
222
+
223
+                    b.Property<string>("Description");
224
+
225
+                    b.Property<bool>("IsBasePrice");
226
+
227
+                    b.Property<bool>("IsDeleted");
228
+
229
+                    b.Property<int?>("MenuCategoryId");
230
+
231
+                    b.Property<int>("MenuItemId");
232
+
233
+                    b.Property<DateTime>("Modified");
234
+
235
+                    b.Property<string>("ModifiedBy");
236
+
237
+                    b.Property<int>("OptionLimit");
238
+
239
+                    b.Property<int>("OptionType");
240
+
241
+                    b.Property<int>("Rank");
242
+
243
+                    b.Property<int>("RestaurantId");
244
+
245
+                    b.HasKey("Id");
246
+
247
+                    b.HasIndex("MenuCategoryId");
248
+
249
+                    b.HasIndex("RestaurantId");
250
+
251
+                    b.ToTable("MenuOptions");
252
+                });
253
+
254
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
255
+                {
256
+                    b.Property<int>("Id")
257
+                        .ValueGeneratedOnAdd()
258
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
259
+
260
+                    b.Property<DateTime>("Created");
261
+
262
+                    b.Property<string>("Description");
263
+
264
+                    b.Property<bool>("IsDeleted");
265
+
266
+                    b.Property<int?>("MenuOptionId");
267
+
268
+                    b.Property<DateTime>("Modified");
269
+
270
+                    b.Property<string>("ModifiedBy");
271
+
272
+                    b.Property<decimal>("Price");
273
+
274
+                    b.Property<int>("Rank");
275
+
276
+                    b.HasKey("Id");
277
+
278
+                    b.HasIndex("MenuOptionId");
279
+
280
+                    b.ToTable("MenuOptionItems");
281
+                });
282
+
283
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
284
+                {
285
+                    b.Property<int>("Id")
286
+                        .ValueGeneratedOnAdd()
287
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
288
+
289
+                    b.Property<string>("Categories");
290
+
291
+                    b.Property<string>("City");
292
+
293
+                    b.Property<string>("Country");
294
+
295
+                    b.Property<DateTime>("Created");
296
+
297
+                    b.Property<decimal>("DeliveryFee");
298
+
299
+                    b.Property<decimal>("DeliveryRadius");
300
+
301
+                    b.Property<string>("DeliveryTime");
302
+
303
+                    b.Property<string>("GoogleMapUrl");
304
+
305
+                    b.Property<bool>("IsDeleted");
306
+
307
+                    b.Property<decimal>("Latitude");
308
+
309
+                    b.Property<string>("Logo");
310
+
311
+                    b.Property<decimal>("Longitude");
312
+
313
+                    b.Property<string>("MethodsOfPayment");
314
+
315
+                    b.Property<DateTime>("Modified");
316
+
317
+                    b.Property<string>("ModifiedBy");
318
+
319
+                    b.Property<string>("Name");
320
+
321
+                    b.Property<string>("PostalCode");
322
+
323
+                    b.Property<string>("Province");
324
+
325
+                    b.Property<string>("ShopNumber");
326
+
327
+                    b.Property<string>("ShoppingCentre");
328
+
329
+                    b.Property<string>("StreetName");
330
+
331
+                    b.Property<string>("StreetNumber");
332
+
333
+                    b.Property<string>("Suburb");
334
+
335
+                    b.HasKey("Id");
336
+
337
+                    b.ToTable("Restaurants");
338
+                });
339
+
340
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantCategory", b =>
341
+                {
342
+                    b.Property<int>("Id")
343
+                        .ValueGeneratedOnAdd()
344
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
345
+
346
+                    b.Property<string>("Description");
347
+
348
+                    b.Property<string>("Image");
349
+
350
+                    b.HasKey("Id");
351
+
352
+                    b.ToTable("RestaurantCategories");
353
+                });
354
+
355
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
356
+                {
357
+                    b.Property<int>("Id")
358
+                        .ValueGeneratedOnAdd()
359
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
360
+
361
+                    b.Property<DateTime>("Created");
362
+
363
+                    b.Property<bool>("IsDeleted");
364
+
365
+                    b.Property<DateTime>("Modified");
366
+
367
+                    b.Property<string>("ModifiedBy");
368
+
369
+                    b.Property<int>("RestaurantId");
370
+
371
+                    b.Property<int>("UserId");
372
+
373
+                    b.HasKey("Id");
374
+
375
+                    b.HasIndex("RestaurantId");
376
+
377
+                    b.HasIndex("UserId");
378
+
379
+                    b.ToTable("RestaurantUsers");
380
+                });
381
+
382
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
383
+                {
384
+                    b.Property<int>("Id")
385
+                        .ValueGeneratedOnAdd()
386
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
387
+
388
+                    b.Property<bool>("Closed");
389
+
390
+                    b.Property<DateTime>("ClosingTime");
391
+
392
+                    b.Property<DateTime>("Created");
393
+
394
+                    b.Property<string>("Description");
395
+
396
+                    b.Property<bool>("IsDeleted");
397
+
398
+                    b.Property<DateTime>("Modified");
399
+
400
+                    b.Property<string>("ModifiedBy");
401
+
402
+                    b.Property<bool>("Opened24H");
403
+
404
+                    b.Property<DateTime>("OpeningTime");
405
+
406
+                    b.Property<int>("RestaurantId");
407
+
408
+                    b.HasKey("Id");
409
+
410
+                    b.HasIndex("RestaurantId");
411
+
412
+                    b.ToTable("TradingHours");
413
+                });
414
+
415
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
416
+                {
417
+                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
418
+                        .WithOne("DriverDetails")
419
+                        .HasForeignKey("ProRestaurant.Models.Accounts.DriverDetail", "UserId")
420
+                        .OnDelete(DeleteBehavior.Cascade);
421
+                });
422
+
423
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
424
+                {
425
+                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
426
+                        .WithMany("Addresses")
427
+                        .HasForeignKey("UserId")
428
+                        .OnDelete(DeleteBehavior.Cascade);
429
+                });
430
+
431
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
432
+                {
433
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
434
+                        .WithMany()
435
+                        .HasForeignKey("RestaurantId")
436
+                        .OnDelete(DeleteBehavior.Cascade);
437
+                });
438
+
439
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
440
+                {
441
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
442
+                        .WithMany()
443
+                        .HasForeignKey("RestaurantId")
444
+                        .OnDelete(DeleteBehavior.Cascade);
445
+                });
446
+
447
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
448
+                {
449
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuCategory")
450
+                        .WithMany("Options")
451
+                        .HasForeignKey("MenuCategoryId");
452
+
453
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
454
+                        .WithMany()
455
+                        .HasForeignKey("RestaurantId")
456
+                        .OnDelete(DeleteBehavior.Cascade);
457
+                });
458
+
459
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
460
+                {
461
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuOption", "MenuOption")
462
+                        .WithMany("Options")
463
+                        .HasForeignKey("MenuOptionId");
464
+                });
465
+
466
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
467
+                {
468
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
469
+                        .WithMany("Users")
470
+                        .HasForeignKey("RestaurantId")
471
+                        .OnDelete(DeleteBehavior.Cascade);
472
+
473
+                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
474
+                        .WithMany()
475
+                        .HasForeignKey("UserId")
476
+                        .OnDelete(DeleteBehavior.Cascade);
477
+                });
478
+
479
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
480
+                {
481
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
482
+                        .WithMany("TradingHours")
483
+                        .HasForeignKey("RestaurantId")
484
+                        .OnDelete(DeleteBehavior.Cascade);
485
+                });
486
+#pragma warning restore 612, 618
487
+        }
488
+    }
489
+}

+ 23
- 0
ProRestaurant/Migrations/20200706125622_User add password flag.cs View File

@@ -0,0 +1,23 @@
1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace ProRestaurant.Migrations
4
+{
5
+    public partial class Useraddpasswordflag : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.AddColumn<bool>(
10
+                name: "ChangePassword",
11
+                table: "Users",
12
+                nullable: false,
13
+                defaultValue: false);
14
+        }
15
+
16
+        protected override void Down(MigrationBuilder migrationBuilder)
17
+        {
18
+            migrationBuilder.DropColumn(
19
+                name: "ChangePassword",
20
+                table: "Users");
21
+        }
22
+    }
23
+}

+ 19
- 4
ProRestaurant/Migrations/DBContextModelSnapshot.cs View File

@@ -55,6 +55,8 @@ namespace ProRestaurant.Migrations
55 55
 
56 56
                     b.Property<string>("Cellphone");
57 57
 
58
+                    b.Property<bool>("ChangePassword");
59
+
58 60
                     b.Property<DateTime>("Created");
59 61
 
60 62
                     b.Property<string>("EmailAddress");
@@ -191,6 +193,8 @@ namespace ProRestaurant.Migrations
191 193
 
192 194
                     b.Property<string>("Name");
193 195
 
196
+                    b.Property<bool>("OutOfStock");
197
+
194 198
                     b.Property<bool>("OverrideOptions");
195 199
 
196 200
                     b.Property<decimal>("Price");
@@ -210,7 +214,7 @@ namespace ProRestaurant.Migrations
210 214
                         .ValueGeneratedOnAdd()
211 215
                         .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
212 216
 
213
-                    b.Property<int?>("CategoryId");
217
+                    b.Property<int>("CategoryId");
214 218
 
215 219
                     b.Property<DateTime>("Created");
216 220
 
@@ -220,6 +224,8 @@ namespace ProRestaurant.Migrations
220 224
 
221 225
                     b.Property<bool>("IsDeleted");
222 226
 
227
+                    b.Property<int?>("MenuCategoryId");
228
+
223 229
                     b.Property<int>("MenuItemId");
224 230
 
225 231
                     b.Property<DateTime>("Modified");
@@ -232,9 +238,13 @@ namespace ProRestaurant.Migrations
232 238
 
233 239
                     b.Property<int>("Rank");
234 240
 
241
+                    b.Property<int>("RestaurantId");
242
+
235 243
                     b.HasKey("Id");
236 244
 
237
-                    b.HasIndex("CategoryId");
245
+                    b.HasIndex("MenuCategoryId");
246
+
247
+                    b.HasIndex("RestaurantId");
238 248
 
239 249
                     b.ToTable("MenuOptions");
240 250
                 });
@@ -434,9 +444,14 @@ namespace ProRestaurant.Migrations
434 444
 
435 445
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
436 446
                 {
437
-                    b.HasOne("ProRestaurant.Models.Restaurants.MenuCategory", "Category")
447
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuCategory")
438 448
                         .WithMany("Options")
439
-                        .HasForeignKey("CategoryId");
449
+                        .HasForeignKey("MenuCategoryId");
450
+
451
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
452
+                        .WithMany()
453
+                        .HasForeignKey("RestaurantId")
454
+                        .OnDelete(DeleteBehavior.Cascade);
440 455
                 });
441 456
 
442 457
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>

+ 2
- 4
ProRestaurant/Models/Accounts/User.cs View File

@@ -1,8 +1,5 @@
1 1
 using ProRestaurant.Classes;
2
-using System;
3 2
 using System.Collections.Generic;
4
-using System.Linq;
5
-using System.Threading.Tasks;
6 3
 
7 4
 namespace ProRestaurant.Models.Accounts
8 5
 {
@@ -14,8 +11,9 @@ namespace ProRestaurant.Models.Accounts
14 11
         public string Surname { get; set; }
15 12
         public string Cellphone { get; set; }
16 13
         public SystemRole SystemRole { get; set; }
14
+        public bool ChangePassword { get; set; }
17 15
 
18
-        public virtual DriverDetail DriverDetails { get; set; }
16
+        public virtual DriverDetail DriverDetails { get; set; }        
19 17
 
20 18
         public ICollection<UserAddress> Addresses { get; set; }
21 19
     }    

+ 1
- 0
ProRestaurant/Models/Restaurants/MenuItem.cs View File

@@ -13,6 +13,7 @@ namespace ProRestaurant.Models.Restaurants
13 13
         public string Description { get; set; }
14 14
         public decimal Price { get; set; }
15 15
         public bool OverrideOptions { get; set; }
16
+        public bool OutOfStock { get; set; }
16 17
 
17 18
         public virtual Restaurant Restaurant { get; set; }        
18 19
 

+ 6
- 4
ProRestaurant/Models/Restaurants/MenuOption.cs View File

@@ -5,8 +5,10 @@ using System.ComponentModel.DataAnnotations.Schema;
5 5
 namespace ProRestaurant.Models.Restaurants
6 6
 {
7 7
     public class MenuOption : BaseObject
8
-    {                   
9
-        public int? CategoryId { get; set; }
8
+    {             
9
+        [ForeignKey("Restaurant")]
10
+        public int RestaurantId { get; set; }
11
+        public int CategoryId { get; set; }
10 12
         public string Description { get; set; }
11 13
         public OptionType OptionType { get; set; }
12 14
         public int OptionLimit { get; set; }
@@ -14,8 +16,8 @@ namespace ProRestaurant.Models.Restaurants
14 16
         public int Rank { get; set; }
15 17
         public int MenuItemId { get; set; }
16 18
 
17
-        public ICollection<MenuOptionItem> Options { get; set; }        
18
-        public virtual MenuCategory Category { get; set; }
19
+        public ICollection<MenuOptionItem> Options { get; set; }                
20
+        public virtual Restaurant Restaurant { get; set; }
19 21
 
20 22
         [NotMapped]
21 23
         public string CategoryDescription { get; set; }

+ 61
- 8
ProRestaurant/Repository/Restaurants/IMenuRepository.cs View File

@@ -11,7 +11,7 @@ namespace ProRestaurant.Repository.Restaurants
11 11
     public interface IMenuRepository
12 12
     {
13 13
         RestaurantMenuContainer GetMenu(int restaurantId);
14
-        MenuContainer GetOptions(int MenuID, int CategoryID);
14
+        MenuContainer GetOptions(int MenuID);
15 15
     }
16 16
 
17 17
     public class MenuRepository : IMenuRepository
@@ -67,11 +67,12 @@ namespace ProRestaurant.Repository.Restaurants
67 67
                         Name = item.Name,
68 68
                         Description = item.Description,
69 69
                         Price = string.Format("{0:C}", item.Price),
70
-                        Image = item.Image.StartsWith("data:image") ? item.Image : ImageFormatter.ImageToBase64(item.Image)
70
+                        Image = !string.IsNullOrEmpty(item.Image) ? item.Image.StartsWith("data:image") ? item.Image : ImageFormatter.ImageToBase64(item.Image) : ""
71 71
                     });
72 72
                 }
73 73
 
74
-                menu.MenuList.Add(menuItem);
74
+                if (menuItem.Items.Count > 0)
75
+                    menu.MenuList.Add(menuItem);
75 76
             }
76 77
 
77 78
             var tradingHours = dBContext.TradingHours.Where(t => t.RestaurantId == restaurantId).ToList();
@@ -95,7 +96,7 @@ namespace ProRestaurant.Repository.Restaurants
95 96
             return menu;
96 97
         }
97 98
 
98
-        public MenuContainer GetOptions(int MenuID, int CategoryID)
99
+        public MenuContainer GetOptions(int MenuID)
99 100
         {            
100 101
             var mItem = dBContext.MenuItems.Where(m => m.Id == MenuID).FirstOrDefault();
101 102
 
@@ -105,13 +106,18 @@ namespace ProRestaurant.Repository.Restaurants
105 106
                 Name = mItem.Name,
106 107
                 Description = mItem.Description,
107 108
                 Price = mItem.Price,
108
-                DisplayPrice = string.Format("{0:C}", mItem.Price),
109
-                Image = mItem.Image.StartsWith("data:image") ? mItem.Image : ImageFormatter.ImageToBase64(mItem.Image),
109
+                DisplayPrice = string.Format("{0:C}", mItem.Price),       
110
+                Image = "",
110 111
                 Options = new List<OptionContainer>()
111 112
             };
112 113
 
114
+            if (!string.IsNullOrEmpty(mItem.Image))
115
+            {
116
+                menu.Image = mItem.Image.StartsWith("data:image") ? mItem.Image : ImageFormatter.ImageToBase64(mItem.Image);
117
+            }
113 118
 
114
-            var menuOptions = dBContext.MenuOptions.Where(mo => mo.CategoryId == CategoryID).OrderBy(mo => mo.Rank).ToList();
119
+            //Menu's options
120
+            var menuOptions = dBContext.MenuOptions.Where(mo => mo.MenuItemId == mItem.Id).OrderBy(mo => mo.Rank).ToList();
115 121
 
116 122
             foreach (var option in menuOptions)
117 123
             {
@@ -143,6 +149,7 @@ namespace ProRestaurant.Repository.Restaurants
143 149
                 {
144 150
                     opt.Options.Add(new OptionItemContainer()
145 151
                     {
152
+                        Id = item.Id,
146 153
                         Description = item.Description,
147 154
                         Price = item.Price
148 155
                     });
@@ -150,8 +157,52 @@ namespace ProRestaurant.Repository.Restaurants
150 157
                 menu.Options.Add(opt);
151 158
             }
152 159
 
160
+            if (!mItem.OverrideOptions)
161
+            {
162
+                //Category's Options
163
+                menuOptions = dBContext.MenuOptions.Where(mo => mo.CategoryId == mItem.CategoryId).OrderBy(mo => mo.Rank).ToList();
153 164
 
154
-            menuOptions = dBContext.MenuOptions.Where(mo => mo.CategoryId == null).OrderBy(mo => mo.Rank).ToList();
165
+                foreach (var option in menuOptions)
166
+                {
167
+                    OptionContainer opt = new OptionContainer
168
+                    {
169
+                        Description = option.Description,
170
+                        OptionType = option.OptionType.ToString(),
171
+                        Limit = option.OptionLimit,
172
+                        IsBasePrice = option.IsBasePrice,
173
+                        SpecialInstructions = "",
174
+                        Options = new List<OptionItemContainer>()
175
+                    };
176
+
177
+                    switch (option.OptionType)
178
+                    {
179
+                        case OptionType.SingleRequired:
180
+                            opt.SubTitle = "Required";
181
+                            break;
182
+                        case OptionType.MultipleLimit:
183
+                            opt.SubTitle = string.Format("Choose {0}", opt.Limit);
184
+                            break;
185
+                        default:
186
+                            opt.SubTitle = "";
187
+                            break;
188
+                    }
189
+
190
+                    var menuItems = dBContext.MenuOptionItems.Where(i => i.MenuOption == option).OrderBy(i => i.Rank).ToList();
191
+                    foreach (var item in menuItems)
192
+                    {
193
+                        opt.Options.Add(new OptionItemContainer()
194
+                        {
195
+                            Id = item.Id,
196
+                            Description = item.Description,
197
+                            Price = item.Price                            
198
+                        });
199
+                    }
200
+                    menu.Options.Add(opt);
201
+                }
202
+            }
203
+
204
+            //All Cat Options
205
+            menuOptions = dBContext.MenuOptions.Where(mo => mo.CategoryId == 0 && mo.RestaurantId == mItem.RestaurantId).OrderBy(mo => mo.Rank).ToList();
155 206
 
156 207
             foreach (var option in menuOptions)
157 208
             {
@@ -183,6 +234,7 @@ namespace ProRestaurant.Repository.Restaurants
183 234
                 {
184 235
                     opt.Options.Add(new OptionItemContainer()
185 236
                     {
237
+                        Id = item.Id,
186 238
                         Description = item.Description,
187 239
                         Price = item.Price
188 240
                     });
@@ -190,6 +242,7 @@ namespace ProRestaurant.Repository.Restaurants
190 242
                 menu.Options.Add(opt);
191 243
             }
192 244
 
245
+
193 246
             return menu;
194 247
         }
195 248
     }

+ 95
- 0
ProRestaurant/Repository/Restaurants/IRestaurantUserRepository.cs View File

@@ -0,0 +1,95 @@
1
+using Microsoft.EntityFrameworkCore;
2
+using ProRestaurant.Classes;
3
+using ProRestaurant.DBContexts;
4
+using ProRestaurant.Models.Accounts;
5
+using ProRestaurant.Models.Restaurants;
6
+using System.Collections.Generic;
7
+using System.Linq;
8
+using System.Security.Cryptography.Xml;
9
+
10
+namespace ProRestaurant.Repository.Restaurants
11
+{
12
+    public interface IRestaurantUserRepository
13
+    {
14
+        List<User> GetUsers(int RestaurantId);
15
+        RestaurantUser GetRestaurantUser(int UserId);
16
+        void InsertUser(RestaurantUser User);
17
+        void UpdateUser(RestaurantUser User);
18
+        void RemoveUser(int id);
19
+        void Save();
20
+    }
21
+
22
+    public class RestaurantUserRepository : IRestaurantUserRepository
23
+    {
24
+        private readonly DBContext dBContext;
25
+
26
+        public RestaurantUserRepository(DBContext db)
27
+        {
28
+            dBContext = db;
29
+        }
30
+
31
+        public RestaurantUser GetRestaurantUser(int UserId)
32
+        {
33
+            var restUser = dBContext.RestaurantUsers.Include("User").Where(r => r.UserId == UserId).FirstOrDefault();
34
+
35
+            if (restUser == null)
36
+            {
37
+                restUser = new RestaurantUser
38
+                {
39
+                    User = new User()
40
+                    {
41
+                        Id = 0,
42
+                        EmailAddress = "",
43
+                        FirstName = "",
44
+                        Surname = "",
45
+                        Cellphone = ""
46
+                    }
47
+                };
48
+            }
49
+
50
+            return restUser;
51
+        }
52
+
53
+        public List<User> GetUsers(int RestaurantId)
54
+        {
55
+            var users = dBContext.RestaurantUsers.Include("User").Where(r => r.RestaurantId == RestaurantId).Select(r => r.User).ToList();
56
+            return users;
57
+        }
58
+
59
+        public void InsertUser(RestaurantUser User)
60
+        {
61
+            dBContext.Add(User);
62
+
63
+            string password = CommonFunctions.GenerateRandomPassword();
64
+
65
+            User.User.Password = CommonFunctions.GetHashSHA256(password + "≡∆≤≥√∞ProVision");
66
+            User.User.ChangePassword = true;
67
+            User.User.SystemRole = SystemRole.RestaurantUser;
68
+
69
+            //TODO: Email generated password to the email address
70
+
71
+            Save();
72
+        }
73
+
74
+        public void RemoveUser(int id)
75
+        {
76
+            var user = dBContext.Users.Where(u => u.Id == id).FirstOrDefault();
77
+            var rUser = dBContext.RestaurantUsers.Where(r => r.UserId == user.Id).FirstOrDefault();
78
+
79
+            dBContext.Users.Remove(user);
80
+            dBContext.RestaurantUsers.Remove(rUser);
81
+            Save();
82
+        }
83
+
84
+        public void Save()
85
+        {
86
+            dBContext.SaveChanges();
87
+        }
88
+
89
+        public void UpdateUser(RestaurantUser User)
90
+        {
91
+            dBContext.Entry(User.User).State = EntityState.Modified;
92
+            Save();
93
+        }
94
+    }
95
+}

+ 2
- 3
ProRestaurant/Repository/Restaurants/MenuOptionRepository.cs View File

@@ -87,9 +87,8 @@ namespace ProRestaurant.Repository.Restaurants
87 87
 
88 88
         public List<MenuOption> GetRestaurantMenuOptions(int restaurantId)
89 89
         {
90
-            var options = (from o in dBContext.MenuOptions
91
-                           join c in dBContext.MenuCategories on o.CategoryId equals c.Id
92
-                           where c.RestaurantId == restaurantId
90
+            var options = (from o in dBContext.MenuOptions                           
91
+                           where o.RestaurantId == restaurantId
93 92
                            orderby o.Rank
94 93
                            select o).ToList();
95 94
 

+ 1
- 0
ProRestaurant/Startup.cs View File

@@ -85,6 +85,7 @@ namespace ProRestaurant
85 85
             services.AddTransient<IMenuOptionRepository, MenuOptionRepository>();
86 86
             services.AddTransient<IMenuItemRepository, MenuItemRepository>();
87 87
             services.AddTransient<IMenuRepository, MenuRepository>();
88
+            services.AddTransient<IRestaurantUserRepository, RestaurantUserRepository>();
88 89
 
89 90
             services.Configure<MvcOptions>(options =>
90 91
             {

+ 1
- 1
ProRestaurant/appsettings.json View File

@@ -9,6 +9,6 @@
9 9
   },
10 10
   "AllowedHosts": "*",
11 11
   "ConnectionStrings": {
12
-    "DefaultDatabase": "Data Source=localhost;Initial Catalog=Restaurants;Integrated Security=true;Pooling=false;"
12
+    "DefaultDatabase": "Data Source=localhost;Initial Catalog=RestaurantDemo;Integrated Security=true;Pooling=false;"
13 13
   }
14 14
 }

BIN
ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.dll View File


BIN
ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.pdb View File


+ 1
- 1
ProRestaurant/bin/Debug/netcoreapp2.2/appsettings.json View File

@@ -9,6 +9,6 @@
9 9
   },
10 10
   "AllowedHosts": "*",
11 11
   "ConnectionStrings": {
12
-    "DefaultDatabase": "Data Source=localhost;Initial Catalog=Restaurants;Integrated Security=true;Pooling=false;"
12
+    "DefaultDatabase": "Data Source=localhost;Initial Catalog=RestaurantDemo;Integrated Security=true;Pooling=false;"
13 13
   }
14 14
 }

+ 1
- 1
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csproj.CoreCompileInputs.cache View File

@@ -1 +1 @@
1
-6449f93053b2ae76a77e4da47929d5cb895df3c6
1
+9adf305668e4c84bcd07601f8f7915e6185ed444

BIN
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csprojAssemblyReference.cache View File


BIN
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.dll View File


BIN
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.pdb View File


Loading…
Cancel
Save