Преглед изворни кода

Menu Option & Display WIP

master
George Williams пре 5 година
родитељ
комит
b7caff0dc0
53 измењених фајлова са 1487 додато и 1799 уклоњено
  1. BIN
      .vs/ProRestaurant/DesignTimeBuild/.dtbcache.v2
  2. BIN
      .vs/ProRestaurant/v16/.suo
  3. 8
    0
      ProRestaurant/Classes/Enums.cs
  4. 7
    0
      ProRestaurant/Containers/Category.cs
  5. 10
    0
      ProRestaurant/Containers/MenuCategoryContainer.cs
  6. 12
    0
      ProRestaurant/Containers/MenuItemContainer.cs
  7. 13
    0
      ProRestaurant/Containers/OptionTypeContainer.cs
  8. 13
    0
      ProRestaurant/Containers/RestaurantCard.cs
  9. 17
    13
      ProRestaurant/Containers/RestaurantContainer.cs
  10. 14
    0
      ProRestaurant/Containers/RestaurantDetails.cs
  11. 23
    0
      ProRestaurant/Containers/RestaurantMenuContainer.cs
  12. 8
    0
      ProRestaurant/Containers/TradingHourContainer.cs
  13. 29
    0
      ProRestaurant/Controllers/Restaurants/MenuController.cs
  14. 70
    0
      ProRestaurant/Controllers/Restaurants/MenuItemController.cs
  15. 77
    0
      ProRestaurant/Controllers/Restaurants/MenuOptionsController.cs
  16. 27
    73
      ProRestaurant/DBContexts/DBContext.cs
  17. 0
    369
      ProRestaurant/Migrations/20200608091919_ReInitDB.Designer.cs
  18. 0
    371
      ProRestaurant/Migrations/20200608113150_001.Designer.cs
  19. 0
    23
      ProRestaurant/Migrations/20200608113150_001.cs
  20. 0
    388
      ProRestaurant/Migrations/20200608133845_002.Designer.cs
  21. 0
    48
      ProRestaurant/Migrations/20200608133845_002.cs
  22. 0
    386
      ProRestaurant/Migrations/20200608133952_003.Designer.cs
  23. 0
    31
      ProRestaurant/Migrations/20200609191325_004.cs
  24. 0
    23
      ProRestaurant/Migrations/20200611111141_005.cs
  25. 0
    23
      ProRestaurant/Migrations/20200611113345_007.cs
  26. 83
    2
      ProRestaurant/Migrations/20200630140752_Recreate Database.Designer.cs
  27. 103
    10
      ProRestaurant/Migrations/20200630140752_Recreate Database.cs
  28. 87
    4
      ProRestaurant/Migrations/20200630143357_MenuItem Override added.Designer.cs
  29. 9
    9
      ProRestaurant/Migrations/20200630143357_MenuItem Override added.cs
  30. 91
    6
      ProRestaurant/Migrations/20200703060514_Province Spelling fix.Designer.cs
  31. 3
    3
      ProRestaurant/Migrations/20200703060514_Province Spelling fix.cs
  32. 88
    6
      ProRestaurant/Migrations/20200703123907_MenuOption FK nullable to Category.Designer.cs
  33. 50
    0
      ProRestaurant/Migrations/20200703123907_MenuOption FK nullable to Category.cs
  34. 83
    1
      ProRestaurant/Migrations/DBContextModelSnapshot.cs
  35. 3
    1
      ProRestaurant/Models/Restaurants/MenuCategory.cs
  36. 11
    2
      ProRestaurant/Models/Restaurants/MenuItem.cs
  37. 25
    0
      ProRestaurant/Models/Restaurants/MenuOption.cs
  38. 10
    0
      ProRestaurant/Models/Restaurants/MenuOptionItem.cs
  39. 2
    2
      ProRestaurant/Models/Restaurants/Restaurant.cs
  40. 3
    3
      ProRestaurant/Repository/Accounts/RegistrationRepository.cs
  41. 0
    1
      ProRestaurant/Repository/Restaurants/IMenuCategoryRepository.cs
  42. 16
    0
      ProRestaurant/Repository/Restaurants/IMenuItemRepository.cs
  43. 19
    0
      ProRestaurant/Repository/Restaurants/IMenuOptionRepository.cs
  44. 196
    0
      ProRestaurant/Repository/Restaurants/IMenuRepository.cs
  45. 120
    0
      ProRestaurant/Repository/Restaurants/MenuItemRepository.cs
  46. 149
    0
      ProRestaurant/Repository/Restaurants/MenuOptionRepository.cs
  47. 7
    0
      ProRestaurant/Startup.cs
  48. BIN
      ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.dll
  49. BIN
      ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.pdb
  50. 1
    1
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csproj.CoreCompileInputs.cache
  51. BIN
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csprojAssemblyReference.cache
  52. BIN
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.dll
  53. BIN
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.pdb

BIN
.vs/ProRestaurant/DesignTimeBuild/.dtbcache.v2 Прегледај датотеку


BIN
.vs/ProRestaurant/v16/.suo Прегледај датотеку


+ 8
- 0
ProRestaurant/Classes/Enums.cs Прегледај датотеку

@@ -12,4 +12,12 @@ namespace ProRestaurant.Classes
12 12
         RestaurantUser,        
13 13
         Customer
14 14
     }
15
+
16
+    public enum OptionType
17
+    {
18
+        Single,
19
+        SingleRequired,
20
+        Multiple, 
21
+        MultipleLimit
22
+    }
15 23
 }

+ 7
- 0
ProRestaurant/Containers/Category.cs Прегледај датотеку

@@ -0,0 +1,7 @@
1
+namespace ProRestaurant.Containers
2
+{
3
+    public class Category
4
+    {
5
+        public string Description { get; set; }
6
+    }
7
+}

+ 10
- 0
ProRestaurant/Containers/MenuCategoryContainer.cs Прегледај датотеку

@@ -0,0 +1,10 @@
1
+using System.Collections.Generic;
2
+
3
+namespace ProRestaurant.Containers
4
+{
5
+    public class MenuCategoryContainer
6
+    {
7
+        public string Category { get; set; }
8
+        public List<MenuItemContainer> Items { get; set; }
9
+    }
10
+}

+ 12
- 0
ProRestaurant/Containers/MenuItemContainer.cs Прегледај датотеку

@@ -0,0 +1,12 @@
1
+namespace ProRestaurant.Containers
2
+{
3
+    public class MenuItemContainer
4
+    {
5
+        public int MenuId { get; set; }
6
+        public int CategoryId { get; set; }
7
+        public string Name { get; set; }
8
+        public string Description { get; set; }
9
+        public string Price { get; set; }
10
+        public string Image { get; set; }
11
+    }
12
+}

+ 13
- 0
ProRestaurant/Containers/OptionTypeContainer.cs Прегледај датотеку

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace ProRestaurant.Containers
7
+{
8
+    public class OptionTypeContainer
9
+    {
10
+        public int Id { get; set; }
11
+        public string Description { get; set; }
12
+    }
13
+}

+ 13
- 0
ProRestaurant/Containers/RestaurantCard.cs Прегледај датотеку

@@ -0,0 +1,13 @@
1
+namespace ProRestaurant.Containers
2
+{
3
+    public class RestaurantCard
4
+    {
5
+        public int Id { get; set; }
6
+        public string Logo { get; set; }
7
+        public string Name { get; set; }
8
+        public string Suburb { get; set; }
9
+        public string SubText { get; set; }
10
+        public string DeliveryTime { get; set; }
11
+        public string DeliveryFee { get; set; }
12
+    }
13
+}

+ 17
- 13
ProRestaurant/Containers/RestaurantContainer.cs Прегледај датотеку

@@ -15,28 +15,32 @@ namespace ProRestaurant.Containers
15 15
         public string Result { get; set; }        
16 16
     }
17 17
 
18
-    public class RestaurantCard
18
+    public class MenuContainer
19 19
     {
20 20
         public int Id { get; set; }
21
-        public string Logo { get; set; }
22 21
         public string Name { get; set; }
23
-        public string Suburb { get; set; }
24
-        public string SubText { get; set; }
25
-        public string DeliveryTime { get; set; }
26
-        public string DeliveryFee { get; set; }
22
+        public string Description { get; set; }
23
+        public string DisplayPrice { get; set; }
24
+        public decimal Price { get; set; }
25
+        public string Image { get; set; }
26
+
27
+        public List<OptionContainer> Options { get; set; }
27 28
     }
28 29
 
29
-    public class RestaurantDetails : Restaurant
30
+    public class OptionContainer
30 31
     {
31
-        public List<string> SelectedMethodsOfPayments { get; set; }
32
-        public List<Category> SavedCategories { get; set; }
33
-        public List<TradingHoursContainer> SavedTradingHours { get; set; }
34
-        public int DeliveryFrom { get; set; }
35
-        public int DeliveryTo { get; set; }
32
+        public string Description { get; set; }
33
+        public string SubTitle { get; set; }
34
+        public string OptionType { get; set; }
35
+        public int Limit { get; set; }
36
+        public bool IsBasePrice { get; set; }          
37
+        public string SpecialInstructions { get; set; }
38
+        public List<OptionItemContainer> Options { get; set; }
36 39
     }
37 40
 
38
-    public class Category
41
+    public class OptionItemContainer
39 42
     {
40 43
         public string Description { get; set; }
44
+        public decimal Price { get; set; }        
41 45
     }
42 46
 }

+ 14
- 0
ProRestaurant/Containers/RestaurantDetails.cs Прегледај датотеку

@@ -0,0 +1,14 @@
1
+using ProRestaurant.Models.Restaurants;
2
+using System.Collections.Generic;
3
+
4
+namespace ProRestaurant.Containers
5
+{
6
+    public class RestaurantDetails : Restaurant
7
+    {
8
+        public List<string> SelectedMethodsOfPayments { get; set; }
9
+        public List<Category> SavedCategories { get; set; }
10
+        public List<TradingHoursContainer> SavedTradingHours { get; set; }
11
+        public int DeliveryFrom { get; set; }
12
+        public int DeliveryTo { get; set; }
13
+    }
14
+}

+ 23
- 0
ProRestaurant/Containers/RestaurantMenuContainer.cs Прегледај датотеку

@@ -0,0 +1,23 @@
1
+using System.Collections.Generic;
2
+
3
+namespace ProRestaurant.Containers
4
+{
5
+    public class RestaurantMenuContainer
6
+    {
7
+        public int Id { get; set; }
8
+        public string Name { get; set; }
9
+        public string Categories { get; set; }
10
+        public string DeliveryTime { get; set; }
11
+        public string DeliveryFee { get; set; }
12
+        public string Suburb { get; set; }
13
+        public string City { get; set; }
14
+        public string Province { get; set; }
15
+        public string PostalCode { get; set; }
16
+        public decimal Latitude { get; set; }
17
+        public decimal Longitude { get; set; }
18
+        public string Logo { get; set; }
19
+        public List<string> CategoryList { get; set; }
20
+        public List<TradingHourContainer> TradingHours { get; set; }
21
+        public List<MenuCategoryContainer> MenuList { get; set; }
22
+    }
23
+}

+ 8
- 0
ProRestaurant/Containers/TradingHourContainer.cs Прегледај датотеку

@@ -0,0 +1,8 @@
1
+namespace ProRestaurant.Containers
2
+{
3
+    public class TradingHourContainer
4
+    {
5
+        public string Description { get; set; }
6
+        public string Time { get; set; }
7
+    }
8
+}

+ 29
- 0
ProRestaurant/Controllers/Restaurants/MenuController.cs Прегледај датотеку

@@ -0,0 +1,29 @@
1
+using Microsoft.AspNetCore.Mvc;
2
+using ProRestaurant.Repository.Restaurants;
3
+
4
+namespace ProRestaurant.Controllers.Restaurants
5
+{
6
+    [Route("api/[controller]")]
7
+    [ApiController]
8
+    public class MenuController : ControllerBase
9
+    {
10
+        private readonly IMenuRepository repo;
11
+
12
+        public MenuController(IMenuRepository _repo)
13
+        {
14
+            repo = _repo;
15
+        }
16
+                
17
+        [HttpGet("{id}")]
18
+        public IActionResult Get(int id)
19
+        {
20
+            return new OkObjectResult(repo.GetMenu(id));
21
+        }
22
+
23
+        [HttpGet("GetOptions/{menuId}/{categoryId}")]
24
+        public IActionResult GetOptions(int menuId, int categoryId)
25
+        {
26
+            return new OkObjectResult(repo.GetOptions(menuId, categoryId));
27
+        }
28
+    }
29
+}

+ 70
- 0
ProRestaurant/Controllers/Restaurants/MenuItemController.cs Прегледај датотеку

@@ -0,0 +1,70 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using System.Transactions;
6
+using Microsoft.AspNetCore.Mvc;
7
+using ProRestaurant.Models.Restaurants;
8
+using ProRestaurant.Repository.Restaurants;
9
+
10
+// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
11
+
12
+namespace ProRestaurant.Controllers.Restaurants
13
+{
14
+    [Route("api/[controller]")]
15
+    [ApiController]
16
+    public class MenuItemController : ControllerBase
17
+    {
18
+        private readonly IMenuItemRepository repo;
19
+
20
+        public MenuItemController(IMenuItemRepository _repo)
21
+        {
22
+            repo = _repo;
23
+        }
24
+
25
+        [HttpGet("{id}")]
26
+        public IActionResult Get(int id)
27
+        {
28
+            return new OkObjectResult(repo.GetMenuItems(r => r.RestaurantId == id));
29
+        }
30
+
31
+        [HttpGet("GetMenuItem/{id}")]
32
+        public IActionResult GetMenuItem(int id)
33
+        {
34
+            return new OkObjectResult(repo.GetMenuItem(id));
35
+        }
36
+
37
+        [HttpPost]
38
+        public IActionResult Post([FromBody] MenuItem item)
39
+        {
40
+            using (var scope = new TransactionScope())
41
+            {
42
+                repo.Insert(item);
43
+                scope.Complete();
44
+                return CreatedAtAction(nameof(Get), new { id = item.Id }, item);
45
+            }
46
+        }
47
+
48
+        [HttpPut]
49
+        public IActionResult Put([FromBody] MenuItem item)
50
+        {
51
+            if (item != null)
52
+            {
53
+                using (var scope = new TransactionScope())
54
+                {
55
+                    repo.Update(item);
56
+                    scope.Complete();
57
+                    return new OkResult();
58
+                }
59
+            }
60
+            return new NoContentResult();
61
+        }
62
+
63
+        [HttpDelete("{id}")]
64
+        public IActionResult Delete(int id)
65
+        {
66
+            repo.Remove(repo.GetMenuItems(u => u.Id == id).FirstOrDefault());
67
+            return new OkResult();
68
+        }
69
+    }
70
+}

+ 77
- 0
ProRestaurant/Controllers/Restaurants/MenuOptionsController.cs Прегледај датотеку

@@ -0,0 +1,77 @@
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 MenuOptionsController : ControllerBase
11
+    {
12
+        public readonly IMenuOptionRepository repo;
13
+
14
+        public MenuOptionsController(IMenuOptionRepository _repo)
15
+        {
16
+            repo = _repo;
17
+        }
18
+
19
+        [HttpGet("{id}")]
20
+        public IActionResult Get(int id)
21
+        {
22
+            return new OkObjectResult(repo.GetMenuOption(id));
23
+        }
24
+
25
+        [HttpGet("GetRestaurantMenuOptions/{id}")]
26
+        public IActionResult GetRestaurantMenuOptions(int id)
27
+        {
28
+            return new OkObjectResult(repo.GetRestaurantMenuOptions(id));
29
+        }
30
+
31
+        [HttpGet("GetOptionTypes")]
32
+        public IActionResult GetOptionTypes()
33
+        {
34
+            return new OkObjectResult(repo.GetOptionTypes());
35
+        }
36
+
37
+        [HttpPost]
38
+        public IActionResult Post([FromBody] MenuOption value)
39
+        {
40
+            using (var scope = new TransactionScope())
41
+            {
42
+                repo.Insert(value);
43
+                scope.Complete();
44
+                return CreatedAtAction(nameof(Get), new { id = value.Id }, value);
45
+            }
46
+        }        
47
+
48
+        [HttpPut]
49
+        public IActionResult Put([FromBody] MenuOption value)
50
+        {
51
+            if (value != null)
52
+            {
53
+                using (var scope = new TransactionScope())
54
+                {
55
+                    repo.Update(value);
56
+                    scope.Complete();
57
+                    return new OkResult();
58
+                }
59
+            }
60
+            return new NoContentResult();
61
+        }
62
+        
63
+        [HttpDelete("{id}")]
64
+        public IActionResult Delete(int id)
65
+        {
66
+            repo.Delete(repo.GetMenuOption(id));
67
+            return new OkResult();
68
+        }
69
+
70
+        [HttpDelete("DeleteMenuOptionItem/{id}")]
71
+        public IActionResult DeleteMenuOptionItem(int id)
72
+        {
73
+            repo.DeleteItem(id);
74
+            return new OkResult();
75
+        }
76
+    }
77
+}

+ 27
- 73
ProRestaurant/DBContexts/DBContext.cs Прегледај датотеку

@@ -1,11 +1,9 @@
1
-using Microsoft.CodeAnalysis;
2
-using Microsoft.EntityFrameworkCore;
3
-using Npgsql;
1
+using Microsoft.EntityFrameworkCore;
2
+using ProRestaurant.Containers;
4 3
 using ProRestaurant.Models;
5 4
 using ProRestaurant.Models.Accounts;
6 5
 using ProRestaurant.Models.Misc;
7 6
 using ProRestaurant.Models.Restaurants;
8
-using System.Data.SqlClient;
9 7
 using System.Linq;
10 8
 
11 9
 namespace ProRestaurant.DBContexts
@@ -16,20 +14,7 @@ namespace ProRestaurant.DBContexts
16 14
         private bool UseSQL = false;
17 15
         public DBContext(DbContextOptions<DBContext> options) 
18 16
             : base(options)
19
-        {
20
-            foreach (var extention in options.Extensions)
21
-            {
22
-                if (extention.GetType().ToString() == "Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.NpgsqlOptionsExtension")
23
-                {
24
-                    connectionString = ((Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.NpgsqlOptionsExtension)extention).ConnectionString;
25
-                    UseSQL = false;
26
-                }
27
-                if (extention.GetType().ToString() == "Microsoft.EntityFrameworkCore.SqlServer.Infrastructure.Internal.SqlServerOptionsExtension")
28
-                {
29
-                    connectionString = ((Microsoft.EntityFrameworkCore.SqlServer.Infrastructure.Internal.SqlServerOptionsExtension)extention).ConnectionString;
30
-                    UseSQL = true;
31
-                }
32
-            }
17
+        {            
33 18
         }
34 19
 
35 20
         #region Accounts
@@ -43,6 +28,8 @@ namespace ProRestaurant.DBContexts
43 28
         public DbSet<TradingHours> TradingHours { get; set; }
44 29
         public DbSet<MenuCategory> MenuCategories { get; set; }
45 30
         public DbSet<MenuItem> MenuItems { get; set; }
31
+        public DbSet<MenuOption> MenuOptions { get; set; }
32
+        public DbSet<MenuOptionItem> MenuOptionItems { get; set; }
46 33
         public DbSet<RestaurantUser> RestaurantUsers { get; set; }
47 34
         public DbSet<RestaurantCategory> RestaurantCategories { get; set; }
48 35
         #endregion
@@ -52,8 +39,7 @@ namespace ProRestaurant.DBContexts
52 39
         #endregion
53 40
 
54 41
         public override int SaveChanges()
55
-        {
56
-            bool isBaseObject = false;
42
+        {            
57 43
             foreach (var item in ChangeTracker
58 44
                                     .Entries()
59 45
                                     .Where(x => x.State == EntityState.Modified || x.State == EntityState.Added)
@@ -61,13 +47,11 @@ namespace ProRestaurant.DBContexts
61 47
                                     .ToList())
62 48
             {
63 49
                 if (item is BaseObject)
64
-                {
65
-                    isBaseObject = true;
50
+                {                    
66 51
                     (item as BaseObject).UpdateModified(string.Empty);
67 52
                 }
68
-            }
69
-            if (isBaseObject)
70
-                UpdateSoftDeleteStatuses();
53
+            }            
54
+            UpdateSoftDeleteStatuses();
71 55
 
72 56
             return base.SaveChanges();
73 57
         }
@@ -75,22 +59,28 @@ namespace ProRestaurant.DBContexts
75 59
         private void UpdateSoftDeleteStatuses()
76 60
         {            
77 61
             foreach (var entry in ChangeTracker.Entries())
78
-            {                
79
-                switch (entry.State)
62
+            {
63
+                var props = (from p in entry.CurrentValues.Properties
64
+                             select p.Name).ToList();
65
+
66
+                if (props.Contains("IsDeleted"))
80 67
                 {
81
-                    case EntityState.Added:
82
-                        entry.CurrentValues["IsDeleted"] = false;
83
-                        break;
84
-                    case EntityState.Deleted:
85
-                        entry.State = EntityState.Modified;
86
-                        entry.CurrentValues["IsDeleted"] = true;
87
-                        break;
68
+                    switch (entry.State)
69
+                    {
70
+                        case EntityState.Added:
71
+                            entry.CurrentValues["IsDeleted"] = false;
72
+                            break;
73
+                        case EntityState.Deleted:
74
+                            entry.State = EntityState.Modified;
75
+                            entry.CurrentValues["IsDeleted"] = true;
76
+                            break;
77
+                    }
88 78
                 }
89 79
             }
90 80
         }
91 81
 
92 82
         protected override void OnModelCreating(ModelBuilder modelBuilder)
93
-        {
83
+        {            
94 84
             modelBuilder.Entity<User>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
95 85
             modelBuilder.Entity<UserAddress>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
96 86
             modelBuilder.Entity<DriverDetail>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
@@ -98,45 +88,9 @@ namespace ProRestaurant.DBContexts
98 88
             modelBuilder.Entity<TradingHours>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
99 89
             modelBuilder.Entity<MenuCategory>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
100 90
             modelBuilder.Entity<MenuItem>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
91
+            modelBuilder.Entity<MenuOption>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
92
+            modelBuilder.Entity<MenuOptionItem>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
101 93
             modelBuilder.Entity<RestaurantUser>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);            
102 94
         }
103
-
104
-        public int GetNextID(string tableName)
105
-        {
106
-            int returnValue = 0;
107
-            if (!UseSQL)
108
-            {
109
-                NpgsqlConnection connection = new NpgsqlConnection(connectionString);
110
-                connection.Open();
111
-
112
-                NpgsqlCommand cmd = connection.CreateCommand();
113
-                cmd.CommandText = string.Format("select MAX(\"Id\") from \"{0}\"", tableName);
114
-                NpgsqlDataReader reader = cmd.ExecuteReader();                
115
-
116
-                while (reader.Read())
117
-                {
118
-                    returnValue = int.Parse(reader[0] == null ? "0" : reader[0].ToString() == "" ? "0" : reader[0].ToString());
119
-                }
120
-
121
-                connection.Close();
122
-            }
123
-            else
124
-            {
125
-                SqlConnection connection = new SqlConnection(connectionString);
126
-                connection.Open();
127
-
128
-                SqlCommand cmd = connection.CreateCommand();
129
-                cmd.CommandText = string.Format("select MAX(\"Id\") from \"{0}\"", tableName);
130
-                SqlDataReader reader = cmd.ExecuteReader();                
131
-
132
-                while (reader.Read())
133
-                {
134
-                    returnValue = int.Parse(reader[0] == null ? "0" : reader[0].ToString() == "" ? "0" : reader[0].ToString());
135
-                }
136
-
137
-                connection.Close();
138
-            }
139
-            return returnValue + 1;
140
-        }
141 95
     }
142 96
 }

+ 0
- 369
ProRestaurant/Migrations/20200608091919_ReInitDB.Designer.cs Прегледај датотеку

@@ -1,369 +0,0 @@
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("20200608091919_ReInitDB")]
14
-    partial class ReInitDB
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>("IsDefault");
100
-
101
-                    b.Property<bool>("IsDeleted");
102
-
103
-                    b.Property<decimal>("Latitude");
104
-
105
-                    b.Property<decimal>("Longitude");
106
-
107
-                    b.Property<DateTime>("Modified");
108
-
109
-                    b.Property<string>("ModifiedBy");
110
-
111
-                    b.Property<string>("PostalCode");
112
-
113
-                    b.Property<string>("Provice");
114
-
115
-                    b.Property<string>("SteetNumber");
116
-
117
-                    b.Property<string>("StreetName");
118
-
119
-                    b.Property<string>("Suburb");
120
-
121
-                    b.Property<string>("UnitNumber");
122
-
123
-                    b.Property<int>("UserId");
124
-
125
-                    b.HasKey("Id");
126
-
127
-                    b.HasIndex("UserId");
128
-
129
-                    b.ToTable("UserAddresses");
130
-                });
131
-
132
-            modelBuilder.Entity("ProRestaurant.Models.Misc.Locations", b =>
133
-                {
134
-                    b.Property<int>("Id")
135
-                        .ValueGeneratedOnAdd()
136
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
137
-
138
-                    b.Property<string>("ImageStore");
139
-
140
-                    b.HasKey("Id");
141
-
142
-                    b.ToTable("Locations");
143
-                });
144
-
145
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
146
-                {
147
-                    b.Property<int>("Id")
148
-                        .ValueGeneratedOnAdd()
149
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
150
-
151
-                    b.Property<DateTime>("Created");
152
-
153
-                    b.Property<string>("Description");
154
-
155
-                    b.Property<bool>("IsDeleted");
156
-
157
-                    b.Property<DateTime>("Modified");
158
-
159
-                    b.Property<string>("ModifiedBy");
160
-
161
-                    b.Property<int>("RestaurantId");
162
-
163
-                    b.HasKey("Id");
164
-
165
-                    b.HasIndex("RestaurantId");
166
-
167
-                    b.ToTable("MenuCategories");
168
-                });
169
-
170
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
171
-                {
172
-                    b.Property<int>("Id")
173
-                        .ValueGeneratedOnAdd()
174
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
175
-
176
-                    b.Property<int>("CategoryId");
177
-
178
-                    b.Property<DateTime>("Created");
179
-
180
-                    b.Property<string>("Description");
181
-
182
-                    b.Property<string>("Image");
183
-
184
-                    b.Property<bool>("IsDeleted");
185
-
186
-                    b.Property<DateTime>("Modified");
187
-
188
-                    b.Property<string>("ModifiedBy");
189
-
190
-                    b.Property<decimal>("Price");
191
-
192
-                    b.Property<int>("RestaurantId");
193
-
194
-                    b.HasKey("Id");
195
-
196
-                    b.HasIndex("RestaurantId");
197
-
198
-                    b.ToTable("MenuItems");
199
-                });
200
-
201
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
202
-                {
203
-                    b.Property<int>("Id")
204
-                        .ValueGeneratedOnAdd()
205
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
206
-
207
-                    b.Property<bool>("Chain");
208
-
209
-                    b.Property<string>("City");
210
-
211
-                    b.Property<string>("Country");
212
-
213
-                    b.Property<DateTime>("Created");
214
-
215
-                    b.Property<decimal>("DeliveryFee");
216
-
217
-                    b.Property<decimal>("DeliveryRadius");
218
-
219
-                    b.Property<string>("GoogleMapUrl");
220
-
221
-                    b.Property<bool>("IsDeleted");
222
-
223
-                    b.Property<decimal>("Latitude");
224
-
225
-                    b.Property<string>("Logo");
226
-
227
-                    b.Property<decimal>("Longitude");
228
-
229
-                    b.Property<string>("MethodsOfPayment");
230
-
231
-                    b.Property<DateTime>("Modified");
232
-
233
-                    b.Property<string>("ModifiedBy");
234
-
235
-                    b.Property<string>("Name");
236
-
237
-                    b.Property<string>("PostalCode");
238
-
239
-                    b.Property<string>("Provice");
240
-
241
-                    b.Property<string>("ShopNumber");
242
-
243
-                    b.Property<string>("ShoppingCentre");
244
-
245
-                    b.Property<string>("StreetName");
246
-
247
-                    b.Property<string>("StreetNumber");
248
-
249
-                    b.Property<string>("Suburb");
250
-
251
-                    b.HasKey("Id");
252
-
253
-                    b.ToTable("Restaurants");
254
-                });
255
-
256
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
257
-                {
258
-                    b.Property<int>("Id")
259
-                        .ValueGeneratedOnAdd()
260
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
261
-
262
-                    b.Property<DateTime>("Created");
263
-
264
-                    b.Property<bool>("IsDeleted");
265
-
266
-                    b.Property<DateTime>("Modified");
267
-
268
-                    b.Property<string>("ModifiedBy");
269
-
270
-                    b.Property<int>("RestaurantId");
271
-
272
-                    b.Property<int>("UserId");
273
-
274
-                    b.HasKey("Id");
275
-
276
-                    b.HasIndex("RestaurantId");
277
-
278
-                    b.HasIndex("UserId");
279
-
280
-                    b.ToTable("RestaurantUsers");
281
-                });
282
-
283
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
284
-                {
285
-                    b.Property<int>("Id")
286
-                        .ValueGeneratedOnAdd()
287
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
288
-
289
-                    b.Property<bool>("Closed");
290
-
291
-                    b.Property<DateTime>("ClosingTime");
292
-
293
-                    b.Property<DateTime>("Created");
294
-
295
-                    b.Property<string>("Description");
296
-
297
-                    b.Property<bool>("IsDeleted");
298
-
299
-                    b.Property<DateTime>("Modified");
300
-
301
-                    b.Property<string>("ModifiedBy");
302
-
303
-                    b.Property<DateTime>("OpeningTime");
304
-
305
-                    b.Property<int>("RestaurantId");
306
-
307
-                    b.HasKey("Id");
308
-
309
-                    b.HasIndex("RestaurantId");
310
-
311
-                    b.ToTable("TradingHours");
312
-                });
313
-
314
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
315
-                {
316
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
317
-                        .WithOne("DriverDetails")
318
-                        .HasForeignKey("ProRestaurant.Models.Accounts.DriverDetail", "UserId")
319
-                        .OnDelete(DeleteBehavior.Cascade);
320
-                });
321
-
322
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
323
-                {
324
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
325
-                        .WithMany("Addresses")
326
-                        .HasForeignKey("UserId")
327
-                        .OnDelete(DeleteBehavior.Cascade);
328
-                });
329
-
330
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
331
-                {
332
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
333
-                        .WithMany()
334
-                        .HasForeignKey("RestaurantId")
335
-                        .OnDelete(DeleteBehavior.Cascade);
336
-                });
337
-
338
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
339
-                {
340
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
341
-                        .WithMany()
342
-                        .HasForeignKey("RestaurantId")
343
-                        .OnDelete(DeleteBehavior.Cascade);
344
-                });
345
-
346
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
347
-                {
348
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
349
-                        .WithMany("Users")
350
-                        .HasForeignKey("RestaurantId")
351
-                        .OnDelete(DeleteBehavior.Cascade);
352
-
353
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
354
-                        .WithMany()
355
-                        .HasForeignKey("UserId")
356
-                        .OnDelete(DeleteBehavior.Cascade);
357
-                });
358
-
359
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
360
-                {
361
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
362
-                        .WithMany("TradingHours")
363
-                        .HasForeignKey("RestaurantId")
364
-                        .OnDelete(DeleteBehavior.Cascade);
365
-                });
366
-#pragma warning restore 612, 618
367
-        }
368
-    }
369
-}

+ 0
- 371
ProRestaurant/Migrations/20200608113150_001.Designer.cs Прегледај датотеку

@@ -1,371 +0,0 @@
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("20200608113150_001")]
14
-    partial class _001
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>("IsDefault");
100
-
101
-                    b.Property<bool>("IsDeleted");
102
-
103
-                    b.Property<decimal>("Latitude");
104
-
105
-                    b.Property<decimal>("Longitude");
106
-
107
-                    b.Property<DateTime>("Modified");
108
-
109
-                    b.Property<string>("ModifiedBy");
110
-
111
-                    b.Property<string>("PostalCode");
112
-
113
-                    b.Property<string>("Provice");
114
-
115
-                    b.Property<string>("SteetNumber");
116
-
117
-                    b.Property<string>("StreetName");
118
-
119
-                    b.Property<string>("Suburb");
120
-
121
-                    b.Property<string>("UnitNumber");
122
-
123
-                    b.Property<int>("UserId");
124
-
125
-                    b.HasKey("Id");
126
-
127
-                    b.HasIndex("UserId");
128
-
129
-                    b.ToTable("UserAddresses");
130
-                });
131
-
132
-            modelBuilder.Entity("ProRestaurant.Models.Misc.Locations", b =>
133
-                {
134
-                    b.Property<int>("Id")
135
-                        .ValueGeneratedOnAdd()
136
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
137
-
138
-                    b.Property<string>("ImageStore");
139
-
140
-                    b.HasKey("Id");
141
-
142
-                    b.ToTable("Locations");
143
-                });
144
-
145
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
146
-                {
147
-                    b.Property<int>("Id")
148
-                        .ValueGeneratedOnAdd()
149
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
150
-
151
-                    b.Property<DateTime>("Created");
152
-
153
-                    b.Property<string>("Description");
154
-
155
-                    b.Property<bool>("IsDeleted");
156
-
157
-                    b.Property<DateTime>("Modified");
158
-
159
-                    b.Property<string>("ModifiedBy");
160
-
161
-                    b.Property<int>("RestaurantId");
162
-
163
-                    b.HasKey("Id");
164
-
165
-                    b.HasIndex("RestaurantId");
166
-
167
-                    b.ToTable("MenuCategories");
168
-                });
169
-
170
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
171
-                {
172
-                    b.Property<int>("Id")
173
-                        .ValueGeneratedOnAdd()
174
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
175
-
176
-                    b.Property<int>("CategoryId");
177
-
178
-                    b.Property<DateTime>("Created");
179
-
180
-                    b.Property<string>("Description");
181
-
182
-                    b.Property<string>("Image");
183
-
184
-                    b.Property<bool>("IsDeleted");
185
-
186
-                    b.Property<DateTime>("Modified");
187
-
188
-                    b.Property<string>("ModifiedBy");
189
-
190
-                    b.Property<decimal>("Price");
191
-
192
-                    b.Property<int>("RestaurantId");
193
-
194
-                    b.HasKey("Id");
195
-
196
-                    b.HasIndex("RestaurantId");
197
-
198
-                    b.ToTable("MenuItems");
199
-                });
200
-
201
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
202
-                {
203
-                    b.Property<int>("Id")
204
-                        .ValueGeneratedOnAdd()
205
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
206
-
207
-                    b.Property<bool>("Chain");
208
-
209
-                    b.Property<string>("City");
210
-
211
-                    b.Property<string>("Country");
212
-
213
-                    b.Property<DateTime>("Created");
214
-
215
-                    b.Property<decimal>("DeliveryFee");
216
-
217
-                    b.Property<decimal>("DeliveryRadius");
218
-
219
-                    b.Property<string>("GoogleMapUrl");
220
-
221
-                    b.Property<bool>("IsDeleted");
222
-
223
-                    b.Property<decimal>("Latitude");
224
-
225
-                    b.Property<string>("Logo");
226
-
227
-                    b.Property<decimal>("Longitude");
228
-
229
-                    b.Property<string>("MethodsOfPayment");
230
-
231
-                    b.Property<DateTime>("Modified");
232
-
233
-                    b.Property<string>("ModifiedBy");
234
-
235
-                    b.Property<string>("Name");
236
-
237
-                    b.Property<string>("PostalCode");
238
-
239
-                    b.Property<string>("Provice");
240
-
241
-                    b.Property<string>("ShopNumber");
242
-
243
-                    b.Property<string>("ShoppingCentre");
244
-
245
-                    b.Property<string>("StreetName");
246
-
247
-                    b.Property<string>("StreetNumber");
248
-
249
-                    b.Property<string>("Suburb");
250
-
251
-                    b.HasKey("Id");
252
-
253
-                    b.ToTable("Restaurants");
254
-                });
255
-
256
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
257
-                {
258
-                    b.Property<int>("Id")
259
-                        .ValueGeneratedOnAdd()
260
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
261
-
262
-                    b.Property<DateTime>("Created");
263
-
264
-                    b.Property<bool>("IsDeleted");
265
-
266
-                    b.Property<DateTime>("Modified");
267
-
268
-                    b.Property<string>("ModifiedBy");
269
-
270
-                    b.Property<int>("RestaurantId");
271
-
272
-                    b.Property<int>("UserId");
273
-
274
-                    b.HasKey("Id");
275
-
276
-                    b.HasIndex("RestaurantId");
277
-
278
-                    b.HasIndex("UserId");
279
-
280
-                    b.ToTable("RestaurantUsers");
281
-                });
282
-
283
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
284
-                {
285
-                    b.Property<int>("Id")
286
-                        .ValueGeneratedOnAdd()
287
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
288
-
289
-                    b.Property<bool>("Closed");
290
-
291
-                    b.Property<DateTime>("ClosingTime");
292
-
293
-                    b.Property<DateTime>("Created");
294
-
295
-                    b.Property<string>("Description");
296
-
297
-                    b.Property<bool>("IsDeleted");
298
-
299
-                    b.Property<DateTime>("Modified");
300
-
301
-                    b.Property<string>("ModifiedBy");
302
-
303
-                    b.Property<bool>("Opened24H");
304
-
305
-                    b.Property<DateTime>("OpeningTime");
306
-
307
-                    b.Property<int>("RestaurantId");
308
-
309
-                    b.HasKey("Id");
310
-
311
-                    b.HasIndex("RestaurantId");
312
-
313
-                    b.ToTable("TradingHours");
314
-                });
315
-
316
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
317
-                {
318
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
319
-                        .WithOne("DriverDetails")
320
-                        .HasForeignKey("ProRestaurant.Models.Accounts.DriverDetail", "UserId")
321
-                        .OnDelete(DeleteBehavior.Cascade);
322
-                });
323
-
324
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
325
-                {
326
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
327
-                        .WithMany("Addresses")
328
-                        .HasForeignKey("UserId")
329
-                        .OnDelete(DeleteBehavior.Cascade);
330
-                });
331
-
332
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
333
-                {
334
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
335
-                        .WithMany()
336
-                        .HasForeignKey("RestaurantId")
337
-                        .OnDelete(DeleteBehavior.Cascade);
338
-                });
339
-
340
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
341
-                {
342
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
343
-                        .WithMany()
344
-                        .HasForeignKey("RestaurantId")
345
-                        .OnDelete(DeleteBehavior.Cascade);
346
-                });
347
-
348
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
349
-                {
350
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
351
-                        .WithMany("Users")
352
-                        .HasForeignKey("RestaurantId")
353
-                        .OnDelete(DeleteBehavior.Cascade);
354
-
355
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
356
-                        .WithMany()
357
-                        .HasForeignKey("UserId")
358
-                        .OnDelete(DeleteBehavior.Cascade);
359
-                });
360
-
361
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
362
-                {
363
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
364
-                        .WithMany("TradingHours")
365
-                        .HasForeignKey("RestaurantId")
366
-                        .OnDelete(DeleteBehavior.Cascade);
367
-                });
368
-#pragma warning restore 612, 618
369
-        }
370
-    }
371
-}

+ 0
- 23
ProRestaurant/Migrations/20200608113150_001.cs Прегледај датотеку

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

+ 0
- 388
ProRestaurant/Migrations/20200608133845_002.Designer.cs Прегледај датотеку

@@ -1,388 +0,0 @@
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("20200608133845_002")]
14
-    partial class _002
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>("IsDefault");
100
-
101
-                    b.Property<bool>("IsDeleted");
102
-
103
-                    b.Property<decimal>("Latitude");
104
-
105
-                    b.Property<decimal>("Longitude");
106
-
107
-                    b.Property<DateTime>("Modified");
108
-
109
-                    b.Property<string>("ModifiedBy");
110
-
111
-                    b.Property<string>("PostalCode");
112
-
113
-                    b.Property<string>("Provice");
114
-
115
-                    b.Property<string>("SteetNumber");
116
-
117
-                    b.Property<string>("StreetName");
118
-
119
-                    b.Property<string>("Suburb");
120
-
121
-                    b.Property<string>("UnitNumber");
122
-
123
-                    b.Property<int>("UserId");
124
-
125
-                    b.HasKey("Id");
126
-
127
-                    b.HasIndex("UserId");
128
-
129
-                    b.ToTable("UserAddresses");
130
-                });
131
-
132
-            modelBuilder.Entity("ProRestaurant.Models.Misc.Locations", b =>
133
-                {
134
-                    b.Property<int>("Id")
135
-                        .ValueGeneratedOnAdd()
136
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
137
-
138
-                    b.Property<string>("ImageStore");
139
-
140
-                    b.HasKey("Id");
141
-
142
-                    b.ToTable("Locations");
143
-                });
144
-
145
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
146
-                {
147
-                    b.Property<int>("Id")
148
-                        .ValueGeneratedOnAdd()
149
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
150
-
151
-                    b.Property<DateTime>("Created");
152
-
153
-                    b.Property<string>("Description");
154
-
155
-                    b.Property<bool>("IsDeleted");
156
-
157
-                    b.Property<DateTime>("Modified");
158
-
159
-                    b.Property<string>("ModifiedBy");
160
-
161
-                    b.Property<int>("RestaurantId");
162
-
163
-                    b.HasKey("Id");
164
-
165
-                    b.HasIndex("RestaurantId");
166
-
167
-                    b.ToTable("MenuCategories");
168
-                });
169
-
170
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
171
-                {
172
-                    b.Property<int>("Id")
173
-                        .ValueGeneratedOnAdd()
174
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
175
-
176
-                    b.Property<int>("CategoryId");
177
-
178
-                    b.Property<DateTime>("Created");
179
-
180
-                    b.Property<string>("Description");
181
-
182
-                    b.Property<string>("Image");
183
-
184
-                    b.Property<bool>("IsDeleted");
185
-
186
-                    b.Property<DateTime>("Modified");
187
-
188
-                    b.Property<string>("ModifiedBy");
189
-
190
-                    b.Property<decimal>("Price");
191
-
192
-                    b.Property<int>("RestaurantId");
193
-
194
-                    b.HasKey("Id");
195
-
196
-                    b.HasIndex("RestaurantId");
197
-
198
-                    b.ToTable("MenuItems");
199
-                });
200
-
201
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
202
-                {
203
-                    b.Property<int>("Id")
204
-                        .ValueGeneratedOnAdd()
205
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
206
-
207
-                    b.Property<string>("Categories");
208
-
209
-                    b.Property<bool>("Chain");
210
-
211
-                    b.Property<string>("City");
212
-
213
-                    b.Property<string>("Country");
214
-
215
-                    b.Property<DateTime>("Created");
216
-
217
-                    b.Property<decimal>("DeliveryFee");
218
-
219
-                    b.Property<decimal>("DeliveryRadius");
220
-
221
-                    b.Property<string>("DeliveryTime");
222
-
223
-                    b.Property<string>("GoogleMapUrl");
224
-
225
-                    b.Property<bool>("IsDeleted");
226
-
227
-                    b.Property<decimal>("Latitude");
228
-
229
-                    b.Property<string>("Logo");
230
-
231
-                    b.Property<decimal>("Longitude");
232
-
233
-                    b.Property<string>("MethodsOfPayment");
234
-
235
-                    b.Property<DateTime>("Modified");
236
-
237
-                    b.Property<string>("ModifiedBy");
238
-
239
-                    b.Property<string>("Name");
240
-
241
-                    b.Property<string>("PostalCode");
242
-
243
-                    b.Property<string>("Provice");
244
-
245
-                    b.Property<string>("ShopNumber");
246
-
247
-                    b.Property<string>("ShoppingCentre");
248
-
249
-                    b.Property<string>("StreetName");
250
-
251
-                    b.Property<string>("StreetNumber");
252
-
253
-                    b.Property<string>("Suburb");
254
-
255
-                    b.HasKey("Id");
256
-
257
-                    b.ToTable("Restaurants");
258
-                });
259
-
260
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantCategory", b =>
261
-                {
262
-                    b.Property<int>("Id")
263
-                        .ValueGeneratedOnAdd()
264
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
265
-
266
-                    b.Property<string>("Description");
267
-
268
-                    b.HasKey("Id");
269
-
270
-                    b.ToTable("RestaurantCategories");
271
-                });
272
-
273
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
274
-                {
275
-                    b.Property<int>("Id")
276
-                        .ValueGeneratedOnAdd()
277
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
278
-
279
-                    b.Property<DateTime>("Created");
280
-
281
-                    b.Property<bool>("IsDeleted");
282
-
283
-                    b.Property<DateTime>("Modified");
284
-
285
-                    b.Property<string>("ModifiedBy");
286
-
287
-                    b.Property<int>("RestaurantId");
288
-
289
-                    b.Property<int>("UserId");
290
-
291
-                    b.HasKey("Id");
292
-
293
-                    b.HasIndex("RestaurantId");
294
-
295
-                    b.HasIndex("UserId");
296
-
297
-                    b.ToTable("RestaurantUsers");
298
-                });
299
-
300
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
301
-                {
302
-                    b.Property<int>("Id")
303
-                        .ValueGeneratedOnAdd()
304
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
305
-
306
-                    b.Property<bool>("Closed");
307
-
308
-                    b.Property<DateTime>("ClosingTime");
309
-
310
-                    b.Property<DateTime>("Created");
311
-
312
-                    b.Property<string>("Description");
313
-
314
-                    b.Property<bool>("IsDeleted");
315
-
316
-                    b.Property<DateTime>("Modified");
317
-
318
-                    b.Property<string>("ModifiedBy");
319
-
320
-                    b.Property<bool>("Opened24H");
321
-
322
-                    b.Property<DateTime>("OpeningTime");
323
-
324
-                    b.Property<int>("RestaurantId");
325
-
326
-                    b.HasKey("Id");
327
-
328
-                    b.HasIndex("RestaurantId");
329
-
330
-                    b.ToTable("TradingHours");
331
-                });
332
-
333
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
334
-                {
335
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
336
-                        .WithOne("DriverDetails")
337
-                        .HasForeignKey("ProRestaurant.Models.Accounts.DriverDetail", "UserId")
338
-                        .OnDelete(DeleteBehavior.Cascade);
339
-                });
340
-
341
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
342
-                {
343
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
344
-                        .WithMany("Addresses")
345
-                        .HasForeignKey("UserId")
346
-                        .OnDelete(DeleteBehavior.Cascade);
347
-                });
348
-
349
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
350
-                {
351
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
352
-                        .WithMany()
353
-                        .HasForeignKey("RestaurantId")
354
-                        .OnDelete(DeleteBehavior.Cascade);
355
-                });
356
-
357
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
358
-                {
359
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
360
-                        .WithMany()
361
-                        .HasForeignKey("RestaurantId")
362
-                        .OnDelete(DeleteBehavior.Cascade);
363
-                });
364
-
365
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
366
-                {
367
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
368
-                        .WithMany("Users")
369
-                        .HasForeignKey("RestaurantId")
370
-                        .OnDelete(DeleteBehavior.Cascade);
371
-
372
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
373
-                        .WithMany()
374
-                        .HasForeignKey("UserId")
375
-                        .OnDelete(DeleteBehavior.Cascade);
376
-                });
377
-
378
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
379
-                {
380
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
381
-                        .WithMany("TradingHours")
382
-                        .HasForeignKey("RestaurantId")
383
-                        .OnDelete(DeleteBehavior.Cascade);
384
-                });
385
-#pragma warning restore 612, 618
386
-        }
387
-    }
388
-}

+ 0
- 48
ProRestaurant/Migrations/20200608133845_002.cs Прегледај датотеку

@@ -1,48 +0,0 @@
1
-using Microsoft.EntityFrameworkCore.Metadata;
2
-using Microsoft.EntityFrameworkCore.Migrations;
3
-
4
-namespace ProRestaurant.Migrations
5
-{
6
-    public partial class _002 : Migration
7
-    {
8
-        protected override void Up(MigrationBuilder migrationBuilder)
9
-        {
10
-            migrationBuilder.AddColumn<string>(
11
-                name: "Categories",
12
-                table: "Restaurants",
13
-                nullable: true);
14
-
15
-            migrationBuilder.AddColumn<string>(
16
-                name: "DeliveryTime",
17
-                table: "Restaurants",
18
-                nullable: true);
19
-
20
-            migrationBuilder.CreateTable(
21
-                name: "RestaurantCategories",
22
-                columns: table => new
23
-                {
24
-                    Id = table.Column<int>(nullable: false)
25
-                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
26
-                    Description = table.Column<string>(nullable: true)
27
-                },
28
-                constraints: table =>
29
-                {
30
-                    table.PrimaryKey("PK_RestaurantCategories", x => x.Id);
31
-                });
32
-        }
33
-
34
-        protected override void Down(MigrationBuilder migrationBuilder)
35
-        {
36
-            migrationBuilder.DropTable(
37
-                name: "RestaurantCategories");
38
-
39
-            migrationBuilder.DropColumn(
40
-                name: "Categories",
41
-                table: "Restaurants");
42
-
43
-            migrationBuilder.DropColumn(
44
-                name: "DeliveryTime",
45
-                table: "Restaurants");
46
-        }
47
-    }
48
-}

+ 0
- 386
ProRestaurant/Migrations/20200608133952_003.Designer.cs Прегледај датотеку

@@ -1,386 +0,0 @@
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("20200608133952_003")]
14
-    partial class _003
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>("IsDefault");
100
-
101
-                    b.Property<bool>("IsDeleted");
102
-
103
-                    b.Property<decimal>("Latitude");
104
-
105
-                    b.Property<decimal>("Longitude");
106
-
107
-                    b.Property<DateTime>("Modified");
108
-
109
-                    b.Property<string>("ModifiedBy");
110
-
111
-                    b.Property<string>("PostalCode");
112
-
113
-                    b.Property<string>("Provice");
114
-
115
-                    b.Property<string>("SteetNumber");
116
-
117
-                    b.Property<string>("StreetName");
118
-
119
-                    b.Property<string>("Suburb");
120
-
121
-                    b.Property<string>("UnitNumber");
122
-
123
-                    b.Property<int>("UserId");
124
-
125
-                    b.HasKey("Id");
126
-
127
-                    b.HasIndex("UserId");
128
-
129
-                    b.ToTable("UserAddresses");
130
-                });
131
-
132
-            modelBuilder.Entity("ProRestaurant.Models.Misc.Locations", b =>
133
-                {
134
-                    b.Property<int>("Id")
135
-                        .ValueGeneratedOnAdd()
136
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
137
-
138
-                    b.Property<string>("ImageStore");
139
-
140
-                    b.HasKey("Id");
141
-
142
-                    b.ToTable("Locations");
143
-                });
144
-
145
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
146
-                {
147
-                    b.Property<int>("Id")
148
-                        .ValueGeneratedOnAdd()
149
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
150
-
151
-                    b.Property<DateTime>("Created");
152
-
153
-                    b.Property<string>("Description");
154
-
155
-                    b.Property<bool>("IsDeleted");
156
-
157
-                    b.Property<DateTime>("Modified");
158
-
159
-                    b.Property<string>("ModifiedBy");
160
-
161
-                    b.Property<int>("RestaurantId");
162
-
163
-                    b.HasKey("Id");
164
-
165
-                    b.HasIndex("RestaurantId");
166
-
167
-                    b.ToTable("MenuCategories");
168
-                });
169
-
170
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
171
-                {
172
-                    b.Property<int>("Id")
173
-                        .ValueGeneratedOnAdd()
174
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
175
-
176
-                    b.Property<int>("CategoryId");
177
-
178
-                    b.Property<DateTime>("Created");
179
-
180
-                    b.Property<string>("Description");
181
-
182
-                    b.Property<string>("Image");
183
-
184
-                    b.Property<bool>("IsDeleted");
185
-
186
-                    b.Property<DateTime>("Modified");
187
-
188
-                    b.Property<string>("ModifiedBy");
189
-
190
-                    b.Property<decimal>("Price");
191
-
192
-                    b.Property<int>("RestaurantId");
193
-
194
-                    b.HasKey("Id");
195
-
196
-                    b.HasIndex("RestaurantId");
197
-
198
-                    b.ToTable("MenuItems");
199
-                });
200
-
201
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
202
-                {
203
-                    b.Property<int>("Id")
204
-                        .ValueGeneratedOnAdd()
205
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
206
-
207
-                    b.Property<string>("Categories");
208
-
209
-                    b.Property<string>("City");
210
-
211
-                    b.Property<string>("Country");
212
-
213
-                    b.Property<DateTime>("Created");
214
-
215
-                    b.Property<decimal>("DeliveryFee");
216
-
217
-                    b.Property<decimal>("DeliveryRadius");
218
-
219
-                    b.Property<string>("DeliveryTime");
220
-
221
-                    b.Property<string>("GoogleMapUrl");
222
-
223
-                    b.Property<bool>("IsDeleted");
224
-
225
-                    b.Property<decimal>("Latitude");
226
-
227
-                    b.Property<string>("Logo");
228
-
229
-                    b.Property<decimal>("Longitude");
230
-
231
-                    b.Property<string>("MethodsOfPayment");
232
-
233
-                    b.Property<DateTime>("Modified");
234
-
235
-                    b.Property<string>("ModifiedBy");
236
-
237
-                    b.Property<string>("Name");
238
-
239
-                    b.Property<string>("PostalCode");
240
-
241
-                    b.Property<string>("Provice");
242
-
243
-                    b.Property<string>("ShopNumber");
244
-
245
-                    b.Property<string>("ShoppingCentre");
246
-
247
-                    b.Property<string>("StreetName");
248
-
249
-                    b.Property<string>("StreetNumber");
250
-
251
-                    b.Property<string>("Suburb");
252
-
253
-                    b.HasKey("Id");
254
-
255
-                    b.ToTable("Restaurants");
256
-                });
257
-
258
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantCategory", b =>
259
-                {
260
-                    b.Property<int>("Id")
261
-                        .ValueGeneratedOnAdd()
262
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
263
-
264
-                    b.Property<string>("Description");
265
-
266
-                    b.HasKey("Id");
267
-
268
-                    b.ToTable("RestaurantCategories");
269
-                });
270
-
271
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
272
-                {
273
-                    b.Property<int>("Id")
274
-                        .ValueGeneratedOnAdd()
275
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
276
-
277
-                    b.Property<DateTime>("Created");
278
-
279
-                    b.Property<bool>("IsDeleted");
280
-
281
-                    b.Property<DateTime>("Modified");
282
-
283
-                    b.Property<string>("ModifiedBy");
284
-
285
-                    b.Property<int>("RestaurantId");
286
-
287
-                    b.Property<int>("UserId");
288
-
289
-                    b.HasKey("Id");
290
-
291
-                    b.HasIndex("RestaurantId");
292
-
293
-                    b.HasIndex("UserId");
294
-
295
-                    b.ToTable("RestaurantUsers");
296
-                });
297
-
298
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
299
-                {
300
-                    b.Property<int>("Id")
301
-                        .ValueGeneratedOnAdd()
302
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
303
-
304
-                    b.Property<bool>("Closed");
305
-
306
-                    b.Property<DateTime>("ClosingTime");
307
-
308
-                    b.Property<DateTime>("Created");
309
-
310
-                    b.Property<string>("Description");
311
-
312
-                    b.Property<bool>("IsDeleted");
313
-
314
-                    b.Property<DateTime>("Modified");
315
-
316
-                    b.Property<string>("ModifiedBy");
317
-
318
-                    b.Property<bool>("Opened24H");
319
-
320
-                    b.Property<DateTime>("OpeningTime");
321
-
322
-                    b.Property<int>("RestaurantId");
323
-
324
-                    b.HasKey("Id");
325
-
326
-                    b.HasIndex("RestaurantId");
327
-
328
-                    b.ToTable("TradingHours");
329
-                });
330
-
331
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
332
-                {
333
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
334
-                        .WithOne("DriverDetails")
335
-                        .HasForeignKey("ProRestaurant.Models.Accounts.DriverDetail", "UserId")
336
-                        .OnDelete(DeleteBehavior.Cascade);
337
-                });
338
-
339
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
340
-                {
341
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
342
-                        .WithMany("Addresses")
343
-                        .HasForeignKey("UserId")
344
-                        .OnDelete(DeleteBehavior.Cascade);
345
-                });
346
-
347
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
348
-                {
349
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
350
-                        .WithMany()
351
-                        .HasForeignKey("RestaurantId")
352
-                        .OnDelete(DeleteBehavior.Cascade);
353
-                });
354
-
355
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
356
-                {
357
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
358
-                        .WithMany()
359
-                        .HasForeignKey("RestaurantId")
360
-                        .OnDelete(DeleteBehavior.Cascade);
361
-                });
362
-
363
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
364
-                {
365
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
366
-                        .WithMany("Users")
367
-                        .HasForeignKey("RestaurantId")
368
-                        .OnDelete(DeleteBehavior.Cascade);
369
-
370
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
371
-                        .WithMany()
372
-                        .HasForeignKey("UserId")
373
-                        .OnDelete(DeleteBehavior.Cascade);
374
-                });
375
-
376
-            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
377
-                {
378
-                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
379
-                        .WithMany("TradingHours")
380
-                        .HasForeignKey("RestaurantId")
381
-                        .OnDelete(DeleteBehavior.Cascade);
382
-                });
383
-#pragma warning restore 612, 618
384
-        }
385
-    }
386
-}

+ 0
- 31
ProRestaurant/Migrations/20200609191325_004.cs Прегледај датотеку

@@ -1,31 +0,0 @@
1
-using Microsoft.EntityFrameworkCore.Migrations;
2
-
3
-namespace ProRestaurant.Migrations
4
-{
5
-    public partial class _004 : Migration
6
-    {
7
-        protected override void Up(MigrationBuilder migrationBuilder)
8
-        {
9
-            migrationBuilder.AddColumn<string>(
10
-                name: "Image",
11
-                table: "RestaurantCategories",
12
-                nullable: true);
13
-
14
-            migrationBuilder.AddColumn<string>(
15
-                name: "CategoryStore",
16
-                table: "Locations",
17
-                nullable: true);
18
-        }
19
-
20
-        protected override void Down(MigrationBuilder migrationBuilder)
21
-        {
22
-            migrationBuilder.DropColumn(
23
-                name: "Image",
24
-                table: "RestaurantCategories");
25
-
26
-            migrationBuilder.DropColumn(
27
-                name: "CategoryStore",
28
-                table: "Locations");
29
-        }
30
-    }
31
-}

+ 0
- 23
ProRestaurant/Migrations/20200611111141_005.cs Прегледај датотеку

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

+ 0
- 23
ProRestaurant/Migrations/20200611113345_007.cs Прегледај датотеку

@@ -1,23 +0,0 @@
1
-using Microsoft.EntityFrameworkCore.Migrations;
2
-
3
-namespace ProRestaurant.Migrations
4
-{
5
-    public partial class _007 : Migration
6
-    {
7
-        protected override void Up(MigrationBuilder migrationBuilder)
8
-        {
9
-            migrationBuilder.RenameColumn(
10
-                name: "SteetNumber",
11
-                table: "UserAddresses",
12
-                newName: "StreetNumber");
13
-        }
14
-
15
-        protected override void Down(MigrationBuilder migrationBuilder)
16
-        {
17
-            migrationBuilder.RenameColumn(
18
-                name: "StreetNumber",
19
-                table: "UserAddresses",
20
-                newName: "SteetNumber");
21
-        }
22
-    }
23
-}

ProRestaurant/Migrations/20200611113345_007.Designer.cs → ProRestaurant/Migrations/20200630140752_Recreate Database.Designer.cs Прегледај датотеку

@@ -10,8 +10,8 @@ using ProRestaurant.DBContexts;
10 10
 namespace ProRestaurant.Migrations
11 11
 {
12 12
     [DbContext(typeof(DBContext))]
13
-    [Migration("20200611113345_007")]
14
-    partial class _007
13
+    [Migration("20200630140752_Recreate Database")]
14
+    partial class RecreateDatabase
15 15
     {
16 16
         protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 17
         {
@@ -191,6 +191,8 @@ namespace ProRestaurant.Migrations
191 191
 
192 192
                     b.Property<string>("ModifiedBy");
193 193
 
194
+                    b.Property<string>("Name");
195
+
194 196
                     b.Property<decimal>("Price");
195 197
 
196 198
                     b.Property<int>("RestaurantId");
@@ -202,6 +204,70 @@ namespace ProRestaurant.Migrations
202 204
                     b.ToTable("MenuItems");
203 205
                 });
204 206
 
207
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
208
+                {
209
+                    b.Property<int>("Id")
210
+                        .ValueGeneratedOnAdd()
211
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
212
+
213
+                    b.Property<int>("CategoryId");
214
+
215
+                    b.Property<DateTime>("Created");
216
+
217
+                    b.Property<string>("Description");
218
+
219
+                    b.Property<bool>("IsBasePrice");
220
+
221
+                    b.Property<bool>("IsDeleted");
222
+
223
+                    b.Property<int>("MenuItemId");
224
+
225
+                    b.Property<DateTime>("Modified");
226
+
227
+                    b.Property<string>("ModifiedBy");
228
+
229
+                    b.Property<int>("OptionLimit");
230
+
231
+                    b.Property<int>("OptionType");
232
+
233
+                    b.Property<int>("Rank");
234
+
235
+                    b.HasKey("Id");
236
+
237
+                    b.HasIndex("CategoryId");
238
+
239
+                    b.ToTable("MenuOptions");
240
+                });
241
+
242
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
243
+                {
244
+                    b.Property<int>("Id")
245
+                        .ValueGeneratedOnAdd()
246
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
247
+
248
+                    b.Property<DateTime>("Created");
249
+
250
+                    b.Property<string>("Description");
251
+
252
+                    b.Property<bool>("IsDeleted");
253
+
254
+                    b.Property<int?>("MenuOptionId");
255
+
256
+                    b.Property<DateTime>("Modified");
257
+
258
+                    b.Property<string>("ModifiedBy");
259
+
260
+                    b.Property<decimal>("Price");
261
+
262
+                    b.Property<int>("Rank");
263
+
264
+                    b.HasKey("Id");
265
+
266
+                    b.HasIndex("MenuOptionId");
267
+
268
+                    b.ToTable("MenuOptionItems");
269
+                });
270
+
205 271
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
206 272
                 {
207 273
                     b.Property<int>("Id")
@@ -366,6 +432,21 @@ namespace ProRestaurant.Migrations
366 432
                         .OnDelete(DeleteBehavior.Cascade);
367 433
                 });
368 434
 
435
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
436
+                {
437
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuCategory", "Category")
438
+                        .WithMany("Options")
439
+                        .HasForeignKey("CategoryId")
440
+                        .OnDelete(DeleteBehavior.Cascade);
441
+                });
442
+
443
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
444
+                {
445
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuOption", "MenuOption")
446
+                        .WithMany("Options")
447
+                        .HasForeignKey("MenuOptionId");
448
+                });
449
+
369 450
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
370 451
                 {
371 452
                     b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")

ProRestaurant/Migrations/20200608091919_ReInitDB.cs → ProRestaurant/Migrations/20200630140752_Recreate Database.cs Прегледај датотеку

@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
4 4
 
5 5
 namespace ProRestaurant.Migrations
6 6
 {
7
-    public partial class ReInitDB : Migration
7
+    public partial class RecreateDatabase : Migration
8 8
     {
9 9
         protected override void Up(MigrationBuilder migrationBuilder)
10 10
         {
@@ -14,13 +14,28 @@ namespace ProRestaurant.Migrations
14 14
                 {
15 15
                     Id = table.Column<int>(nullable: false)
16 16
                         .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
17
-                    ImageStore = table.Column<string>(nullable: true)
17
+                    ImageStore = table.Column<string>(nullable: true),
18
+                    CategoryStore = table.Column<string>(nullable: true)
18 19
                 },
19 20
                 constraints: table =>
20 21
                 {
21 22
                     table.PrimaryKey("PK_Locations", x => x.Id);
22 23
                 });
23 24
 
25
+            migrationBuilder.CreateTable(
26
+                name: "RestaurantCategories",
27
+                columns: table => new
28
+                {
29
+                    Id = table.Column<int>(nullable: false)
30
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
31
+                    Description = table.Column<string>(nullable: true),
32
+                    Image = table.Column<string>(nullable: true)
33
+                },
34
+                constraints: table =>
35
+                {
36
+                    table.PrimaryKey("PK_RestaurantCategories", x => x.Id);
37
+                });
38
+
24 39
             migrationBuilder.CreateTable(
25 40
                 name: "Restaurants",
26 41
                 columns: table => new
@@ -33,7 +48,6 @@ namespace ProRestaurant.Migrations
33 48
                     IsDeleted = table.Column<bool>(nullable: false),
34 49
                     Name = table.Column<string>(nullable: true),
35 50
                     Logo = table.Column<string>(nullable: true),
36
-                    Chain = table.Column<bool>(nullable: false),
37 51
                     DeliveryFee = table.Column<decimal>(nullable: false),
38 52
                     DeliveryRadius = table.Column<decimal>(nullable: false),
39 53
                     MethodsOfPayment = table.Column<string>(nullable: true),
@@ -48,7 +62,9 @@ namespace ProRestaurant.Migrations
48 62
                     City = table.Column<string>(nullable: true),
49 63
                     Provice = table.Column<string>(nullable: true),
50 64
                     Country = table.Column<string>(nullable: true),
51
-                    PostalCode = table.Column<string>(nullable: true)
65
+                    PostalCode = table.Column<string>(nullable: true),
66
+                    DeliveryTime = table.Column<string>(nullable: true),
67
+                    Categories = table.Column<string>(nullable: true)
52 68
                 },
53 69
                 constraints: table =>
54 70
                 {
@@ -114,6 +130,7 @@ namespace ProRestaurant.Migrations
114 130
                     RestaurantId = table.Column<int>(nullable: false),
115 131
                     CategoryId = table.Column<int>(nullable: false),
116 132
                     Image = table.Column<string>(nullable: true),
133
+                    Name = table.Column<string>(nullable: true),
117 134
                     Description = table.Column<string>(nullable: true),
118 135
                     Price = table.Column<decimal>(nullable: false)
119 136
                 },
@@ -142,7 +159,8 @@ namespace ProRestaurant.Migrations
142 159
                     Description = table.Column<string>(nullable: true),
143 160
                     OpeningTime = table.Column<DateTime>(nullable: false),
144 161
                     ClosingTime = table.Column<DateTime>(nullable: false),
145
-                    Closed = table.Column<bool>(nullable: false)
162
+                    Closed = table.Column<bool>(nullable: false),
163
+                    Opened24H = table.Column<bool>(nullable: false)
146 164
                 },
147 165
                 constraints: table =>
148 166
                 {
@@ -222,16 +240,17 @@ namespace ProRestaurant.Migrations
222 240
                     IsDeleted = table.Column<bool>(nullable: false),
223 241
                     UserId = table.Column<int>(nullable: false),
224 242
                     IsDefault = table.Column<bool>(nullable: false),
243
+                    IsComplex = table.Column<bool>(nullable: false),
225 244
                     GoogleMapUrl = table.Column<string>(nullable: true),
226 245
                     Latitude = table.Column<decimal>(nullable: false),
227 246
                     Longitude = table.Column<decimal>(nullable: false),
228 247
                     UnitNumber = table.Column<string>(nullable: true),
229 248
                     ComplexName = table.Column<string>(nullable: true),
230
-                    SteetNumber = table.Column<string>(nullable: true),
249
+                    StreetNumber = table.Column<string>(nullable: true),
231 250
                     StreetName = table.Column<string>(nullable: true),
232 251
                     Suburb = table.Column<string>(nullable: true),
233 252
                     City = table.Column<string>(nullable: true),
234
-                    Provice = table.Column<string>(nullable: true),
253
+                    Province = table.Column<string>(nullable: true),
235 254
                     Country = table.Column<string>(nullable: true),
236 255
                     PostalCode = table.Column<string>(nullable: true)
237 256
                 },
@@ -246,6 +265,61 @@ namespace ProRestaurant.Migrations
246 265
                         onDelete: ReferentialAction.Cascade);
247 266
                 });
248 267
 
268
+            migrationBuilder.CreateTable(
269
+                name: "MenuOptions",
270
+                columns: table => new
271
+                {
272
+                    Id = table.Column<int>(nullable: false)
273
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
274
+                    Created = table.Column<DateTime>(nullable: false),
275
+                    Modified = table.Column<DateTime>(nullable: false),
276
+                    ModifiedBy = table.Column<string>(nullable: true),
277
+                    IsDeleted = table.Column<bool>(nullable: false),
278
+                    CategoryId = table.Column<int>(nullable: false),
279
+                    Description = table.Column<string>(nullable: true),
280
+                    OptionType = table.Column<int>(nullable: false),
281
+                    OptionLimit = table.Column<int>(nullable: false),
282
+                    IsBasePrice = table.Column<bool>(nullable: false),
283
+                    Rank = table.Column<int>(nullable: false),
284
+                    MenuItemId = table.Column<int>(nullable: false)
285
+                },
286
+                constraints: table =>
287
+                {
288
+                    table.PrimaryKey("PK_MenuOptions", x => x.Id);
289
+                    table.ForeignKey(
290
+                        name: "FK_MenuOptions_MenuCategories_CategoryId",
291
+                        column: x => x.CategoryId,
292
+                        principalTable: "MenuCategories",
293
+                        principalColumn: "Id",
294
+                        onDelete: ReferentialAction.Cascade);
295
+                });
296
+
297
+            migrationBuilder.CreateTable(
298
+                name: "MenuOptionItems",
299
+                columns: table => new
300
+                {
301
+                    Id = table.Column<int>(nullable: false)
302
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
303
+                    Created = table.Column<DateTime>(nullable: false),
304
+                    Modified = table.Column<DateTime>(nullable: false),
305
+                    ModifiedBy = table.Column<string>(nullable: true),
306
+                    IsDeleted = table.Column<bool>(nullable: false),
307
+                    MenuOptionId = table.Column<int>(nullable: true),
308
+                    Description = table.Column<string>(nullable: true),
309
+                    Price = table.Column<decimal>(nullable: false),
310
+                    Rank = table.Column<int>(nullable: false)
311
+                },
312
+                constraints: table =>
313
+                {
314
+                    table.PrimaryKey("PK_MenuOptionItems", x => x.Id);
315
+                    table.ForeignKey(
316
+                        name: "FK_MenuOptionItems_MenuOptions_MenuOptionId",
317
+                        column: x => x.MenuOptionId,
318
+                        principalTable: "MenuOptions",
319
+                        principalColumn: "Id",
320
+                        onDelete: ReferentialAction.Restrict);
321
+                });
322
+
249 323
             migrationBuilder.CreateIndex(
250 324
                 name: "IX_DriverDetails_UserId",
251 325
                 table: "DriverDetails",
@@ -262,6 +336,16 @@ namespace ProRestaurant.Migrations
262 336
                 table: "MenuItems",
263 337
                 column: "RestaurantId");
264 338
 
339
+            migrationBuilder.CreateIndex(
340
+                name: "IX_MenuOptionItems_MenuOptionId",
341
+                table: "MenuOptionItems",
342
+                column: "MenuOptionId");
343
+
344
+            migrationBuilder.CreateIndex(
345
+                name: "IX_MenuOptions_CategoryId",
346
+                table: "MenuOptions",
347
+                column: "CategoryId");
348
+
265 349
             migrationBuilder.CreateIndex(
266 350
                 name: "IX_RestaurantUsers_RestaurantId",
267 351
                 table: "RestaurantUsers",
@@ -292,10 +376,13 @@ namespace ProRestaurant.Migrations
292 376
                 name: "Locations");
293 377
 
294 378
             migrationBuilder.DropTable(
295
-                name: "MenuCategories");
379
+                name: "MenuItems");
296 380
 
297 381
             migrationBuilder.DropTable(
298
-                name: "MenuItems");
382
+                name: "MenuOptionItems");
383
+
384
+            migrationBuilder.DropTable(
385
+                name: "RestaurantCategories");
299 386
 
300 387
             migrationBuilder.DropTable(
301 388
                 name: "RestaurantUsers");
@@ -307,10 +394,16 @@ namespace ProRestaurant.Migrations
307 394
                 name: "UserAddresses");
308 395
 
309 396
             migrationBuilder.DropTable(
310
-                name: "Restaurants");
397
+                name: "MenuOptions");
311 398
 
312 399
             migrationBuilder.DropTable(
313 400
                 name: "Users");
401
+
402
+            migrationBuilder.DropTable(
403
+                name: "MenuCategories");
404
+
405
+            migrationBuilder.DropTable(
406
+                name: "Restaurants");
314 407
         }
315 408
     }
316 409
 }

ProRestaurant/Migrations/20200611112655_006.Designer.cs → ProRestaurant/Migrations/20200630143357_MenuItem Override added.Designer.cs Прегледај датотеку

@@ -10,8 +10,8 @@ using ProRestaurant.DBContexts;
10 10
 namespace ProRestaurant.Migrations
11 11
 {
12 12
     [DbContext(typeof(DBContext))]
13
-    [Migration("20200611112655_006")]
14
-    partial class _006
13
+    [Migration("20200630143357_MenuItem Override added")]
14
+    partial class MenuItemOverrideadded
15 15
     {
16 16
         protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 17
         {
@@ -114,10 +114,10 @@ namespace ProRestaurant.Migrations
114 114
 
115 115
                     b.Property<string>("Province");
116 116
 
117
-                    b.Property<string>("SteetNumber");
118
-
119 117
                     b.Property<string>("StreetName");
120 118
 
119
+                    b.Property<string>("StreetNumber");
120
+
121 121
                     b.Property<string>("Suburb");
122 122
 
123 123
                     b.Property<string>("UnitNumber");
@@ -191,6 +191,10 @@ namespace ProRestaurant.Migrations
191 191
 
192 192
                     b.Property<string>("ModifiedBy");
193 193
 
194
+                    b.Property<string>("Name");
195
+
196
+                    b.Property<bool>("OverrideOptions");
197
+
194 198
                     b.Property<decimal>("Price");
195 199
 
196 200
                     b.Property<int>("RestaurantId");
@@ -202,6 +206,70 @@ namespace ProRestaurant.Migrations
202 206
                     b.ToTable("MenuItems");
203 207
                 });
204 208
 
209
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
210
+                {
211
+                    b.Property<int>("Id")
212
+                        .ValueGeneratedOnAdd()
213
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
214
+
215
+                    b.Property<int>("CategoryId");
216
+
217
+                    b.Property<DateTime>("Created");
218
+
219
+                    b.Property<string>("Description");
220
+
221
+                    b.Property<bool>("IsBasePrice");
222
+
223
+                    b.Property<bool>("IsDeleted");
224
+
225
+                    b.Property<int>("MenuItemId");
226
+
227
+                    b.Property<DateTime>("Modified");
228
+
229
+                    b.Property<string>("ModifiedBy");
230
+
231
+                    b.Property<int>("OptionLimit");
232
+
233
+                    b.Property<int>("OptionType");
234
+
235
+                    b.Property<int>("Rank");
236
+
237
+                    b.HasKey("Id");
238
+
239
+                    b.HasIndex("CategoryId");
240
+
241
+                    b.ToTable("MenuOptions");
242
+                });
243
+
244
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
245
+                {
246
+                    b.Property<int>("Id")
247
+                        .ValueGeneratedOnAdd()
248
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
249
+
250
+                    b.Property<DateTime>("Created");
251
+
252
+                    b.Property<string>("Description");
253
+
254
+                    b.Property<bool>("IsDeleted");
255
+
256
+                    b.Property<int?>("MenuOptionId");
257
+
258
+                    b.Property<DateTime>("Modified");
259
+
260
+                    b.Property<string>("ModifiedBy");
261
+
262
+                    b.Property<decimal>("Price");
263
+
264
+                    b.Property<int>("Rank");
265
+
266
+                    b.HasKey("Id");
267
+
268
+                    b.HasIndex("MenuOptionId");
269
+
270
+                    b.ToTable("MenuOptionItems");
271
+                });
272
+
205 273
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
206 274
                 {
207 275
                     b.Property<int>("Id")
@@ -366,6 +434,21 @@ namespace ProRestaurant.Migrations
366 434
                         .OnDelete(DeleteBehavior.Cascade);
367 435
                 });
368 436
 
437
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
438
+                {
439
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuCategory", "Category")
440
+                        .WithMany("Options")
441
+                        .HasForeignKey("CategoryId")
442
+                        .OnDelete(DeleteBehavior.Cascade);
443
+                });
444
+
445
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
446
+                {
447
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuOption", "MenuOption")
448
+                        .WithMany("Options")
449
+                        .HasForeignKey("MenuOptionId");
450
+                });
451
+
369 452
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
370 453
                 {
371 454
                     b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")

ProRestaurant/Migrations/20200608133952_003.cs → ProRestaurant/Migrations/20200630143357_MenuItem Override added.cs Прегледај датотеку

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

ProRestaurant/Migrations/20200609191325_004.Designer.cs → ProRestaurant/Migrations/20200703060514_Province Spelling fix.Designer.cs Прегледај датотеку

@@ -10,8 +10,8 @@ using ProRestaurant.DBContexts;
10 10
 namespace ProRestaurant.Migrations
11 11
 {
12 12
     [DbContext(typeof(DBContext))]
13
-    [Migration("20200609191325_004")]
14
-    partial class _004
13
+    [Migration("20200703060514_Province Spelling fix")]
14
+    partial class ProvinceSpellingfix
15 15
     {
16 16
         protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 17
         {
@@ -96,6 +96,8 @@ namespace ProRestaurant.Migrations
96 96
 
97 97
                     b.Property<string>("GoogleMapUrl");
98 98
 
99
+                    b.Property<bool>("IsComplex");
100
+
99 101
                     b.Property<bool>("IsDefault");
100 102
 
101 103
                     b.Property<bool>("IsDeleted");
@@ -110,12 +112,12 @@ namespace ProRestaurant.Migrations
110 112
 
111 113
                     b.Property<string>("PostalCode");
112 114
 
113
-                    b.Property<string>("Provice");
114
-
115
-                    b.Property<string>("SteetNumber");
115
+                    b.Property<string>("Province");
116 116
 
117 117
                     b.Property<string>("StreetName");
118 118
 
119
+                    b.Property<string>("StreetNumber");
120
+
119 121
                     b.Property<string>("Suburb");
120 122
 
121 123
                     b.Property<string>("UnitNumber");
@@ -189,6 +191,10 @@ namespace ProRestaurant.Migrations
189 191
 
190 192
                     b.Property<string>("ModifiedBy");
191 193
 
194
+                    b.Property<string>("Name");
195
+
196
+                    b.Property<bool>("OverrideOptions");
197
+
192 198
                     b.Property<decimal>("Price");
193 199
 
194 200
                     b.Property<int>("RestaurantId");
@@ -200,6 +206,70 @@ namespace ProRestaurant.Migrations
200 206
                     b.ToTable("MenuItems");
201 207
                 });
202 208
 
209
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
210
+                {
211
+                    b.Property<int>("Id")
212
+                        .ValueGeneratedOnAdd()
213
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
214
+
215
+                    b.Property<int>("CategoryId");
216
+
217
+                    b.Property<DateTime>("Created");
218
+
219
+                    b.Property<string>("Description");
220
+
221
+                    b.Property<bool>("IsBasePrice");
222
+
223
+                    b.Property<bool>("IsDeleted");
224
+
225
+                    b.Property<int>("MenuItemId");
226
+
227
+                    b.Property<DateTime>("Modified");
228
+
229
+                    b.Property<string>("ModifiedBy");
230
+
231
+                    b.Property<int>("OptionLimit");
232
+
233
+                    b.Property<int>("OptionType");
234
+
235
+                    b.Property<int>("Rank");
236
+
237
+                    b.HasKey("Id");
238
+
239
+                    b.HasIndex("CategoryId");
240
+
241
+                    b.ToTable("MenuOptions");
242
+                });
243
+
244
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
245
+                {
246
+                    b.Property<int>("Id")
247
+                        .ValueGeneratedOnAdd()
248
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
249
+
250
+                    b.Property<DateTime>("Created");
251
+
252
+                    b.Property<string>("Description");
253
+
254
+                    b.Property<bool>("IsDeleted");
255
+
256
+                    b.Property<int?>("MenuOptionId");
257
+
258
+                    b.Property<DateTime>("Modified");
259
+
260
+                    b.Property<string>("ModifiedBy");
261
+
262
+                    b.Property<decimal>("Price");
263
+
264
+                    b.Property<int>("Rank");
265
+
266
+                    b.HasKey("Id");
267
+
268
+                    b.HasIndex("MenuOptionId");
269
+
270
+                    b.ToTable("MenuOptionItems");
271
+                });
272
+
203 273
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
204 274
                 {
205 275
                     b.Property<int>("Id")
@@ -240,7 +310,7 @@ namespace ProRestaurant.Migrations
240 310
 
241 311
                     b.Property<string>("PostalCode");
242 312
 
243
-                    b.Property<string>("Provice");
313
+                    b.Property<string>("Province");
244 314
 
245 315
                     b.Property<string>("ShopNumber");
246 316
 
@@ -364,6 +434,21 @@ namespace ProRestaurant.Migrations
364 434
                         .OnDelete(DeleteBehavior.Cascade);
365 435
                 });
366 436
 
437
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
438
+                {
439
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuCategory", "Category")
440
+                        .WithMany("Options")
441
+                        .HasForeignKey("CategoryId")
442
+                        .OnDelete(DeleteBehavior.Cascade);
443
+                });
444
+
445
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
446
+                {
447
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuOption", "MenuOption")
448
+                        .WithMany("Options")
449
+                        .HasForeignKey("MenuOptionId");
450
+                });
451
+
367 452
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
368 453
                 {
369 454
                     b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")

ProRestaurant/Migrations/20200611112655_006.cs → ProRestaurant/Migrations/20200703060514_Province Spelling fix.cs Прегледај датотеку

@@ -2,13 +2,13 @@
2 2
 
3 3
 namespace ProRestaurant.Migrations
4 4
 {
5
-    public partial class _006 : Migration
5
+    public partial class ProvinceSpellingfix : Migration
6 6
     {
7 7
         protected override void Up(MigrationBuilder migrationBuilder)
8 8
         {
9 9
             migrationBuilder.RenameColumn(
10 10
                 name: "Provice",
11
-                table: "UserAddresses",
11
+                table: "Restaurants",
12 12
                 newName: "Province");
13 13
         }
14 14
 
@@ -16,7 +16,7 @@ namespace ProRestaurant.Migrations
16 16
         {
17 17
             migrationBuilder.RenameColumn(
18 18
                 name: "Province",
19
-                table: "UserAddresses",
19
+                table: "Restaurants",
20 20
                 newName: "Provice");
21 21
         }
22 22
     }

ProRestaurant/Migrations/20200611111141_005.Designer.cs → ProRestaurant/Migrations/20200703123907_MenuOption FK nullable to Category.Designer.cs Прегледај датотеку

@@ -10,8 +10,8 @@ using ProRestaurant.DBContexts;
10 10
 namespace ProRestaurant.Migrations
11 11
 {
12 12
     [DbContext(typeof(DBContext))]
13
-    [Migration("20200611111141_005")]
14
-    partial class _005
13
+    [Migration("20200703123907_MenuOption FK nullable to Category")]
14
+    partial class MenuOptionFKnullabletoCategory
15 15
     {
16 16
         protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 17
         {
@@ -112,12 +112,12 @@ namespace ProRestaurant.Migrations
112 112
 
113 113
                     b.Property<string>("PostalCode");
114 114
 
115
-                    b.Property<string>("Provice");
116
-
117
-                    b.Property<string>("SteetNumber");
115
+                    b.Property<string>("Province");
118 116
 
119 117
                     b.Property<string>("StreetName");
120 118
 
119
+                    b.Property<string>("StreetNumber");
120
+
121 121
                     b.Property<string>("Suburb");
122 122
 
123 123
                     b.Property<string>("UnitNumber");
@@ -191,6 +191,10 @@ namespace ProRestaurant.Migrations
191 191
 
192 192
                     b.Property<string>("ModifiedBy");
193 193
 
194
+                    b.Property<string>("Name");
195
+
196
+                    b.Property<bool>("OverrideOptions");
197
+
194 198
                     b.Property<decimal>("Price");
195 199
 
196 200
                     b.Property<int>("RestaurantId");
@@ -202,6 +206,70 @@ namespace ProRestaurant.Migrations
202 206
                     b.ToTable("MenuItems");
203 207
                 });
204 208
 
209
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
210
+                {
211
+                    b.Property<int>("Id")
212
+                        .ValueGeneratedOnAdd()
213
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
214
+
215
+                    b.Property<int?>("CategoryId");
216
+
217
+                    b.Property<DateTime>("Created");
218
+
219
+                    b.Property<string>("Description");
220
+
221
+                    b.Property<bool>("IsBasePrice");
222
+
223
+                    b.Property<bool>("IsDeleted");
224
+
225
+                    b.Property<int>("MenuItemId");
226
+
227
+                    b.Property<DateTime>("Modified");
228
+
229
+                    b.Property<string>("ModifiedBy");
230
+
231
+                    b.Property<int>("OptionLimit");
232
+
233
+                    b.Property<int>("OptionType");
234
+
235
+                    b.Property<int>("Rank");
236
+
237
+                    b.HasKey("Id");
238
+
239
+                    b.HasIndex("CategoryId");
240
+
241
+                    b.ToTable("MenuOptions");
242
+                });
243
+
244
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
245
+                {
246
+                    b.Property<int>("Id")
247
+                        .ValueGeneratedOnAdd()
248
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
249
+
250
+                    b.Property<DateTime>("Created");
251
+
252
+                    b.Property<string>("Description");
253
+
254
+                    b.Property<bool>("IsDeleted");
255
+
256
+                    b.Property<int?>("MenuOptionId");
257
+
258
+                    b.Property<DateTime>("Modified");
259
+
260
+                    b.Property<string>("ModifiedBy");
261
+
262
+                    b.Property<decimal>("Price");
263
+
264
+                    b.Property<int>("Rank");
265
+
266
+                    b.HasKey("Id");
267
+
268
+                    b.HasIndex("MenuOptionId");
269
+
270
+                    b.ToTable("MenuOptionItems");
271
+                });
272
+
205 273
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
206 274
                 {
207 275
                     b.Property<int>("Id")
@@ -242,7 +310,7 @@ namespace ProRestaurant.Migrations
242 310
 
243 311
                     b.Property<string>("PostalCode");
244 312
 
245
-                    b.Property<string>("Provice");
313
+                    b.Property<string>("Province");
246 314
 
247 315
                     b.Property<string>("ShopNumber");
248 316
 
@@ -366,6 +434,20 @@ namespace ProRestaurant.Migrations
366 434
                         .OnDelete(DeleteBehavior.Cascade);
367 435
                 });
368 436
 
437
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
438
+                {
439
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuCategory", "Category")
440
+                        .WithMany("Options")
441
+                        .HasForeignKey("CategoryId");
442
+                });
443
+
444
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
445
+                {
446
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuOption", "MenuOption")
447
+                        .WithMany("Options")
448
+                        .HasForeignKey("MenuOptionId");
449
+                });
450
+
369 451
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
370 452
                 {
371 453
                     b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")

+ 50
- 0
ProRestaurant/Migrations/20200703123907_MenuOption FK nullable to Category.cs Прегледај датотеку

@@ -0,0 +1,50 @@
1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace ProRestaurant.Migrations
4
+{
5
+    public partial class MenuOptionFKnullabletoCategory : 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.AlterColumn<int>(
14
+                name: "CategoryId",
15
+                table: "MenuOptions",
16
+                nullable: true,
17
+                oldClrType: typeof(int));
18
+
19
+            migrationBuilder.AddForeignKey(
20
+                name: "FK_MenuOptions_MenuCategories_CategoryId",
21
+                table: "MenuOptions",
22
+                column: "CategoryId",
23
+                principalTable: "MenuCategories",
24
+                principalColumn: "Id",
25
+                onDelete: ReferentialAction.Restrict);
26
+        }
27
+
28
+        protected override void Down(MigrationBuilder migrationBuilder)
29
+        {
30
+            migrationBuilder.DropForeignKey(
31
+                name: "FK_MenuOptions_MenuCategories_CategoryId",
32
+                table: "MenuOptions");
33
+
34
+            migrationBuilder.AlterColumn<int>(
35
+                name: "CategoryId",
36
+                table: "MenuOptions",
37
+                nullable: false,
38
+                oldClrType: typeof(int),
39
+                oldNullable: true);
40
+
41
+            migrationBuilder.AddForeignKey(
42
+                name: "FK_MenuOptions_MenuCategories_CategoryId",
43
+                table: "MenuOptions",
44
+                column: "CategoryId",
45
+                principalTable: "MenuCategories",
46
+                principalColumn: "Id",
47
+                onDelete: ReferentialAction.Cascade);
48
+        }
49
+    }
50
+}

+ 83
- 1
ProRestaurant/Migrations/DBContextModelSnapshot.cs Прегледај датотеку

@@ -189,6 +189,10 @@ namespace ProRestaurant.Migrations
189 189
 
190 190
                     b.Property<string>("ModifiedBy");
191 191
 
192
+                    b.Property<string>("Name");
193
+
194
+                    b.Property<bool>("OverrideOptions");
195
+
192 196
                     b.Property<decimal>("Price");
193 197
 
194 198
                     b.Property<int>("RestaurantId");
@@ -200,6 +204,70 @@ namespace ProRestaurant.Migrations
200 204
                     b.ToTable("MenuItems");
201 205
                 });
202 206
 
207
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
208
+                {
209
+                    b.Property<int>("Id")
210
+                        .ValueGeneratedOnAdd()
211
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
212
+
213
+                    b.Property<int?>("CategoryId");
214
+
215
+                    b.Property<DateTime>("Created");
216
+
217
+                    b.Property<string>("Description");
218
+
219
+                    b.Property<bool>("IsBasePrice");
220
+
221
+                    b.Property<bool>("IsDeleted");
222
+
223
+                    b.Property<int>("MenuItemId");
224
+
225
+                    b.Property<DateTime>("Modified");
226
+
227
+                    b.Property<string>("ModifiedBy");
228
+
229
+                    b.Property<int>("OptionLimit");
230
+
231
+                    b.Property<int>("OptionType");
232
+
233
+                    b.Property<int>("Rank");
234
+
235
+                    b.HasKey("Id");
236
+
237
+                    b.HasIndex("CategoryId");
238
+
239
+                    b.ToTable("MenuOptions");
240
+                });
241
+
242
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
243
+                {
244
+                    b.Property<int>("Id")
245
+                        .ValueGeneratedOnAdd()
246
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
247
+
248
+                    b.Property<DateTime>("Created");
249
+
250
+                    b.Property<string>("Description");
251
+
252
+                    b.Property<bool>("IsDeleted");
253
+
254
+                    b.Property<int?>("MenuOptionId");
255
+
256
+                    b.Property<DateTime>("Modified");
257
+
258
+                    b.Property<string>("ModifiedBy");
259
+
260
+                    b.Property<decimal>("Price");
261
+
262
+                    b.Property<int>("Rank");
263
+
264
+                    b.HasKey("Id");
265
+
266
+                    b.HasIndex("MenuOptionId");
267
+
268
+                    b.ToTable("MenuOptionItems");
269
+                });
270
+
203 271
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
204 272
                 {
205 273
                     b.Property<int>("Id")
@@ -240,7 +308,7 @@ namespace ProRestaurant.Migrations
240 308
 
241 309
                     b.Property<string>("PostalCode");
242 310
 
243
-                    b.Property<string>("Provice");
311
+                    b.Property<string>("Province");
244 312
 
245 313
                     b.Property<string>("ShopNumber");
246 314
 
@@ -364,6 +432,20 @@ namespace ProRestaurant.Migrations
364 432
                         .OnDelete(DeleteBehavior.Cascade);
365 433
                 });
366 434
 
435
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOption", b =>
436
+                {
437
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuCategory", "Category")
438
+                        .WithMany("Options")
439
+                        .HasForeignKey("CategoryId");
440
+                });
441
+
442
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuOptionItem", b =>
443
+                {
444
+                    b.HasOne("ProRestaurant.Models.Restaurants.MenuOption", "MenuOption")
445
+                        .WithMany("Options")
446
+                        .HasForeignKey("MenuOptionId");
447
+                });
448
+
367 449
             modelBuilder.Entity("ProRestaurant.Models.Restaurants.RestaurantUser", b =>
368 450
                 {
369 451
                     b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")

+ 3
- 1
ProRestaurant/Models/Restaurants/MenuCategory.cs Прегледај датотеку

@@ -1,4 +1,5 @@
1
-using System.ComponentModel.DataAnnotations.Schema;
1
+using System.Collections.Generic;
2
+using System.ComponentModel.DataAnnotations.Schema;
2 3
 
3 4
 namespace ProRestaurant.Models.Restaurants
4 5
 {
@@ -9,5 +10,6 @@ namespace ProRestaurant.Models.Restaurants
9 10
         public string Description { get; set; }
10 11
 
11 12
         public virtual Restaurant Restaurant { get; set; }
13
+        public ICollection<MenuOption> Options { get; set; }
12 14
     }
13 15
 }

+ 11
- 2
ProRestaurant/Models/Restaurants/MenuItem.cs Прегледај датотеку

@@ -1,4 +1,5 @@
1
-using System.ComponentModel.DataAnnotations.Schema;
1
+using System.Collections.Generic;
2
+using System.ComponentModel.DataAnnotations.Schema;
2 3
 
3 4
 namespace ProRestaurant.Models.Restaurants
4 5
 {
@@ -8,9 +9,17 @@ namespace ProRestaurant.Models.Restaurants
8 9
         public int RestaurantId { get; set; }
9 10
         public int CategoryId { get; set; }
10 11
         public string Image { get; set; }
12
+        public string Name { get; set; }
11 13
         public string Description { get; set; }
12 14
         public decimal Price { get; set; }
15
+        public bool OverrideOptions { get; set; }
13 16
 
14
-        public virtual Restaurant Restaurant { get; set; }
17
+        public virtual Restaurant Restaurant { get; set; }        
18
+
19
+        [NotMapped]
20
+        public string Category { get; set; }
21
+
22
+        [NotMapped]
23
+        public ICollection<MenuOption> Options { get; set; }
15 24
     }
16 25
 }

+ 25
- 0
ProRestaurant/Models/Restaurants/MenuOption.cs Прегледај датотеку

@@ -0,0 +1,25 @@
1
+using ProRestaurant.Classes;
2
+using System.Collections.Generic;
3
+using System.ComponentModel.DataAnnotations.Schema;
4
+
5
+namespace ProRestaurant.Models.Restaurants
6
+{
7
+    public class MenuOption : BaseObject
8
+    {                   
9
+        public int? CategoryId { get; set; }
10
+        public string Description { get; set; }
11
+        public OptionType OptionType { get; set; }
12
+        public int OptionLimit { get; set; }
13
+        public bool IsBasePrice { get; set; }
14
+        public int Rank { get; set; }
15
+        public int MenuItemId { get; set; }
16
+
17
+        public ICollection<MenuOptionItem> Options { get; set; }        
18
+        public virtual MenuCategory Category { get; set; }
19
+
20
+        [NotMapped]
21
+        public string CategoryDescription { get; set; }
22
+        [NotMapped]
23
+        public string OptionTypeDescription { get; set; }
24
+    }
25
+}

+ 10
- 0
ProRestaurant/Models/Restaurants/MenuOptionItem.cs Прегледај датотеку

@@ -0,0 +1,10 @@
1
+namespace ProRestaurant.Models.Restaurants
2
+{
3
+    public class MenuOptionItem : BaseObject
4
+    {
5
+        public MenuOption MenuOption { get; set; }
6
+        public string Description { get; set; }
7
+        public decimal Price { get; set; }
8
+        public int Rank { get; set;  }
9
+    }
10
+}

+ 2
- 2
ProRestaurant/Models/Restaurants/Restaurant.cs Прегледај датотеку

@@ -18,13 +18,13 @@ namespace ProRestaurant.Models.Restaurants
18 18
         public string StreetName { get; set; }
19 19
         public string Suburb { get; set; }
20 20
         public string City { get; set; }
21
-        public string Provice { get; set; }
21
+        public string Province { get; set; }
22 22
         public string Country { get; set; }
23 23
         public string PostalCode { get; set; }
24 24
         public string DeliveryTime { get; set; }
25 25
         public string Categories { get; set; }
26 26
 
27 27
         public ICollection<TradingHours> TradingHours { get; set; }   
28
-        public ICollection<RestaurantUser> Users { get; set; }
28
+        public ICollection<RestaurantUser> Users { get; set; }        
29 29
     }
30 30
 }

+ 3
- 3
ProRestaurant/Repository/Accounts/RegistrationRepository.cs Прегледај датотеку

@@ -33,7 +33,7 @@ namespace ProRestaurant.Repository.Accounts
33 33
                 StreetName = "",
34 34
                 Suburb = "",
35 35
                 City = "",
36
-                Provice = "",
36
+                Province = "",
37 37
                 Country = "",
38 38
 
39 39
             };
@@ -79,7 +79,7 @@ namespace ProRestaurant.Repository.Accounts
79 79
 
80 80
         public RestaurantContainer RegisterRestaurant(RestaurantContainer RestaurantContainer)
81 81
         {            
82
-            var restaurantCheck = dBContext.Restaurants.Where(r => r.Name == RestaurantContainer.Name && r.Suburb == RestaurantContainer.Suburb && r.City == RestaurantContainer.City && r.Provice == RestaurantContainer.Provice && r.Country == RestaurantContainer.Country).FirstOrDefault();
82
+            var restaurantCheck = dBContext.Restaurants.Where(r => r.Name == RestaurantContainer.Name && r.Suburb == RestaurantContainer.Suburb && r.City == RestaurantContainer.City && r.Province == RestaurantContainer.Province && r.Country == RestaurantContainer.Country).FirstOrDefault();
83 83
             if (restaurantCheck != null)
84 84
             {
85 85
                 RestaurantContainer.Result = "A Restaurant with the same name has already been registered in this location. ";
@@ -118,7 +118,7 @@ namespace ProRestaurant.Repository.Accounts
118 118
                 StreetName = RestaurantContainer.StreetName,
119 119
                 Suburb = RestaurantContainer.Suburb,
120 120
                 City = RestaurantContainer.City,
121
-                Provice = RestaurantContainer.Provice,
121
+                Province = RestaurantContainer.Province,
122 122
                 Country = RestaurantContainer.Country,
123 123
                 PostalCode = RestaurantContainer.PostalCode,
124 124
                 Categories = RestaurantContainer.Categories

+ 0
- 1
ProRestaurant/Repository/Restaurants/IMenuCategoryRepository.cs Прегледај датотеку

@@ -1,7 +1,6 @@
1 1
 using ProRestaurant.Models.Restaurants;
2 2
 using System;
3 3
 using System.Collections.Generic;
4
-using System.Linq;
5 4
 using System.Threading.Tasks;
6 5
 
7 6
 namespace ProRestaurant.Repository.Restaurants

+ 16
- 0
ProRestaurant/Repository/Restaurants/IMenuItemRepository.cs Прегледај датотеку

@@ -0,0 +1,16 @@
1
+using ProRestaurant.Models.Restaurants;
2
+using System;
3
+using System.Collections.Generic;
4
+
5
+namespace ProRestaurant.Repository.Restaurants
6
+{
7
+    public interface IMenuItemRepository
8
+    {
9
+        MenuItem GetMenuItem(int Id);
10
+        IEnumerable<MenuItem> GetMenuItems(Func<MenuItem, bool> where);
11
+        void Insert(MenuItem Item);
12
+        void Remove(MenuItem Item);
13
+        void Update(MenuItem Item);
14
+        void Save();
15
+    }
16
+}

+ 19
- 0
ProRestaurant/Repository/Restaurants/IMenuOptionRepository.cs Прегледај датотеку

@@ -0,0 +1,19 @@
1
+using ProRestaurant.Containers;
2
+using ProRestaurant.Models.Restaurants;
3
+using System.Collections.Generic;
4
+using System.ComponentModel.DataAnnotations;
5
+
6
+namespace ProRestaurant.Repository.Restaurants
7
+{
8
+    public interface IMenuOptionRepository
9
+    {
10
+        MenuOption GetMenuOption(int id);
11
+        List<MenuOption> GetRestaurantMenuOptions(int restaurantId);
12
+        List<OptionTypeContainer> GetOptionTypes();
13
+        void Insert(MenuOption Option);
14
+        void Update(MenuOption Option);
15
+        void Delete(MenuOption Option);
16
+        void DeleteItem(int id);
17
+        void Save();
18
+    }
19
+}

+ 196
- 0
ProRestaurant/Repository/Restaurants/IMenuRepository.cs Прегледај датотеку

@@ -0,0 +1,196 @@
1
+using ProRestaurant.Classes;
2
+using ProRestaurant.Containers;
3
+using ProRestaurant.DBContexts;
4
+using System;
5
+using System.Collections.Generic;
6
+using System.Linq;
7
+using System.Threading.Tasks;
8
+
9
+namespace ProRestaurant.Repository.Restaurants
10
+{
11
+    public interface IMenuRepository
12
+    {
13
+        RestaurantMenuContainer GetMenu(int restaurantId);
14
+        MenuContainer GetOptions(int MenuID, int CategoryID);
15
+    }
16
+
17
+    public class MenuRepository : IMenuRepository
18
+    {
19
+        private readonly DBContext dBContext;
20
+
21
+        public MenuRepository(DBContext db)
22
+        {
23
+            dBContext = db;
24
+        }
25
+
26
+        public RestaurantMenuContainer GetMenu(int restaurantId)
27
+        {            
28
+            var restaurant = dBContext.Restaurants.Where(r => r.Id == restaurantId).FirstOrDefault();
29
+
30
+            var menu = new RestaurantMenuContainer
31
+            {
32
+                Id = restaurant.Id,
33
+                Name = restaurant.Name,
34
+                Categories = restaurant.Categories,
35
+                DeliveryTime = restaurant.DeliveryTime,
36
+                DeliveryFee = string.Format("R {0:N}", restaurant.DeliveryFee),
37
+                Suburb = restaurant.Suburb,
38
+                City = restaurant.City,
39
+                Province = restaurant.Province,
40
+                PostalCode = restaurant.PostalCode,
41
+                Latitude = restaurant.Latitude,
42
+                Longitude = restaurant.Longitude,
43
+                Logo = restaurant.Logo.StartsWith("data:image") ? restaurant.Logo : ImageFormatter.ImageToBase64(restaurant.Logo),
44
+                CategoryList = new List<string>(),
45
+                TradingHours = new List<TradingHourContainer>(),
46
+                MenuList = new List<MenuCategoryContainer>()
47
+            };
48
+
49
+            var categories = dBContext.MenuCategories.Where(c => c.RestaurantId == restaurantId).ToList();
50
+            foreach (var cat in categories)
51
+            {
52
+                menu.CategoryList.Add(cat.Description);
53
+
54
+                MenuCategoryContainer menuItem = new MenuCategoryContainer
55
+                {
56
+                    Category = cat.Description,
57
+                    Items = new List<MenuItemContainer>()
58
+                };
59
+
60
+                var MenuItems = dBContext.MenuItems.Where(mi => mi.CategoryId == cat.Id).ToList();
61
+                foreach (var item in MenuItems)
62
+                {
63
+                    menuItem.Items.Add(new MenuItemContainer
64
+                    {
65
+                        MenuId = item.Id,
66
+                        CategoryId = item.CategoryId,
67
+                        Name = item.Name,
68
+                        Description = item.Description,
69
+                        Price = string.Format("{0:C}", item.Price),
70
+                        Image = item.Image.StartsWith("data:image") ? item.Image : ImageFormatter.ImageToBase64(item.Image)
71
+                    });
72
+                }
73
+
74
+                menu.MenuList.Add(menuItem);
75
+            }
76
+
77
+            var tradingHours = dBContext.TradingHours.Where(t => t.RestaurantId == restaurantId).ToList();
78
+            foreach (var tHours in tradingHours)
79
+            {
80
+                var hour = new TradingHourContainer()
81
+                {
82
+                    Description = tHours.Description
83
+                };
84
+
85
+                if (tHours.Closed)
86
+                    hour.Time = "Closed";
87
+                else if (tHours.Opened24H)
88
+                    hour.Time = "Open 24 Hours";
89
+                else
90
+                    hour.Time = string.Format("{0:hh:mm} - {1:hh:mm}", tHours.OpeningTime, tHours.ClosingTime);
91
+
92
+                menu.TradingHours.Add(hour);
93
+            }
94
+
95
+            return menu;
96
+        }
97
+
98
+        public MenuContainer GetOptions(int MenuID, int CategoryID)
99
+        {            
100
+            var mItem = dBContext.MenuItems.Where(m => m.Id == MenuID).FirstOrDefault();
101
+
102
+            MenuContainer menu = new MenuContainer
103
+            {
104
+                Id = MenuID,
105
+                Name = mItem.Name,
106
+                Description = mItem.Description,
107
+                Price = mItem.Price,
108
+                DisplayPrice = string.Format("{0:C}", mItem.Price),
109
+                Image = mItem.Image.StartsWith("data:image") ? mItem.Image : ImageFormatter.ImageToBase64(mItem.Image),
110
+                Options = new List<OptionContainer>()
111
+            };
112
+
113
+
114
+            var menuOptions = dBContext.MenuOptions.Where(mo => mo.CategoryId == CategoryID).OrderBy(mo => mo.Rank).ToList();
115
+
116
+            foreach (var option in menuOptions)
117
+            {
118
+                OptionContainer opt = new OptionContainer
119
+                {
120
+                    Description = option.Description,
121
+                    OptionType = option.OptionType.ToString(),
122
+                    Limit = option.OptionLimit,
123
+                    IsBasePrice = option.IsBasePrice,
124
+                    SpecialInstructions = "",
125
+                    Options = new List<OptionItemContainer>()
126
+                };
127
+
128
+                switch (option.OptionType)
129
+                {
130
+                    case OptionType.SingleRequired:
131
+                        opt.SubTitle = "Required";
132
+                        break;
133
+                    case OptionType.MultipleLimit:
134
+                        opt.SubTitle = string.Format("Choose {0}", opt.Limit);
135
+                        break;
136
+                    default:
137
+                        opt.SubTitle = "";
138
+                        break;
139
+                }
140
+
141
+                var menuItems = dBContext.MenuOptionItems.Where(i => i.MenuOption == option).OrderBy(i => i.Rank).ToList();
142
+                foreach (var item in menuItems)
143
+                {
144
+                    opt.Options.Add(new OptionItemContainer()
145
+                    {
146
+                        Description = item.Description,
147
+                        Price = item.Price
148
+                    });
149
+                }
150
+                menu.Options.Add(opt);
151
+            }
152
+
153
+
154
+            menuOptions = dBContext.MenuOptions.Where(mo => mo.CategoryId == null).OrderBy(mo => mo.Rank).ToList();
155
+
156
+            foreach (var option in menuOptions)
157
+            {
158
+                OptionContainer opt = new OptionContainer
159
+                {
160
+                    Description = option.Description,
161
+                    OptionType = option.OptionType.ToString(),
162
+                    Limit = option.OptionLimit,
163
+                    IsBasePrice = option.IsBasePrice,
164
+                    SpecialInstructions = "",
165
+                    Options = new List<OptionItemContainer>()
166
+                };
167
+
168
+                switch (option.OptionType)
169
+                {
170
+                    case OptionType.SingleRequired:
171
+                        opt.SubTitle = "Required";
172
+                        break;
173
+                    case OptionType.MultipleLimit:
174
+                        opt.SubTitle = string.Format("Choose {0}", opt.Limit);
175
+                        break;
176
+                    default:
177
+                        opt.SubTitle = "";
178
+                        break;
179
+                }
180
+
181
+                var menuItems = dBContext.MenuOptionItems.Where(i => i.MenuOption == option).OrderBy(i => i.Rank).ToList();
182
+                foreach (var item in menuItems)
183
+                {
184
+                    opt.Options.Add(new OptionItemContainer()
185
+                    {
186
+                        Description = item.Description,
187
+                        Price = item.Price
188
+                    });
189
+                }
190
+                menu.Options.Add(opt);
191
+            }
192
+
193
+            return menu;
194
+        }
195
+    }
196
+}

+ 120
- 0
ProRestaurant/Repository/Restaurants/MenuItemRepository.cs Прегледај датотеку

@@ -0,0 +1,120 @@
1
+using Microsoft.EntityFrameworkCore;
2
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
3
+using ProRestaurant.Classes;
4
+using ProRestaurant.DBContexts;
5
+using ProRestaurant.Models.Restaurants;
6
+using System;
7
+using System.Collections.Generic;
8
+using System.Drawing;
9
+using System.IO;
10
+using System.Linq;
11
+
12
+namespace ProRestaurant.Repository.Restaurants
13
+{
14
+    public class MenuItemRepository : IMenuItemRepository
15
+    {
16
+        private readonly DBContext dBContext;
17
+
18
+        public MenuItemRepository(DBContext db)
19
+        {
20
+            dBContext = db;
21
+        }
22
+
23
+        public MenuItem GetMenuItem(int Id)
24
+        {
25
+            var item = dBContext.MenuItems.Where(m => m.Id == Id).FirstOrDefault();
26
+
27
+            if (item == null)
28
+            {
29
+                item = new MenuItem();
30
+            }
31
+            else
32
+            {
33
+                if (item.CategoryId > 0)
34
+                    item.Category = dBContext.MenuCategories.Where(c => c.Id == item.CategoryId).Select(c => c.Description).FirstOrDefault();
35
+
36
+                if (!string.IsNullOrEmpty(item.Image))
37
+                {
38
+                    if (!item.Image.Contains("data:image"))
39
+                        item.Image = ImageFormatter.ImageToBase64(item.Image);
40
+                }
41
+
42
+                item.Options = dBContext.MenuOptions.Where(o => o.MenuItemId == item.Id).ToList();
43
+            }
44
+
45
+            return item;
46
+        }
47
+
48
+        public IEnumerable<MenuItem> GetMenuItems(Func<MenuItem, bool> where)
49
+        {
50
+            var items = dBContext.MenuItems.Where(where).ToList();
51
+
52
+            foreach (var item in items)
53
+            {
54
+                if (item.CategoryId > 0)
55
+                    item.Category = dBContext.MenuCategories.Where(c => c.Id == item.CategoryId).Select(c => c.Description).FirstOrDefault();
56
+
57
+                if (!string.IsNullOrEmpty(item.Image))
58
+                {
59
+                    if (!item.Image.Contains("data:image"))
60
+                        item.Image = ImageFormatter.ImageToBase64(item.Image);
61
+                }
62
+            }
63
+
64
+            return items;
65
+        }
66
+
67
+        public void Insert(MenuItem Item)
68
+        {
69
+            Item.Image = SaveImage(Item);
70
+            dBContext.Add(Item);
71
+            Save();
72
+        }
73
+
74
+        public void Remove(MenuItem Item)
75
+        {
76
+            dBContext.MenuItems.Remove(Item);
77
+            Save();
78
+        }
79
+
80
+        public void Save()
81
+        {
82
+            dBContext.SaveChanges();
83
+        }
84
+
85
+        public void Update(MenuItem Item)
86
+        {
87
+            Item.Image = SaveImage(Item);
88
+            dBContext.Entry(Item).State = EntityState.Modified;
89
+            Save();
90
+        }
91
+
92
+        private string SaveImage(MenuItem Item)
93
+        {
94
+            string image = Item.Image;
95
+            if (!string.IsNullOrEmpty(Item.Image))
96
+            {
97
+                bool saveFile = false;
98
+                var loc = dBContext.Locations.FirstOrDefault()?.ImageStore;
99
+                if (!string.IsNullOrEmpty(loc))
100
+                {
101
+                    var rest = dBContext.Restaurants.Where(r => r.Id == Item.RestaurantId).FirstOrDefault();
102
+                    var folderName = rest.Name + "-" + rest.Suburb;
103
+                    saveFile = true;
104
+                    loc += string.Format("{0}", folderName);
105
+                    if (!Directory.Exists(loc))
106
+                    {
107
+                        Directory.CreateDirectory(loc);
108
+                    }
109
+
110
+                    if (saveFile)
111
+                    {
112
+                        string path = ImageFormatter.Base64ToImage(Item.Image, loc, Item.Name.Trim());
113
+                        image = path;
114
+                    }                    
115
+                }
116
+            }
117
+            return image;
118
+        }
119
+    }
120
+}

+ 149
- 0
ProRestaurant/Repository/Restaurants/MenuOptionRepository.cs Прегледај датотеку

@@ -0,0 +1,149 @@
1
+using Microsoft.EntityFrameworkCore;
2
+using ProRestaurant.Classes;
3
+using ProRestaurant.Containers;
4
+using ProRestaurant.DBContexts;
5
+using ProRestaurant.Models.Restaurants;
6
+using System;
7
+using System.Collections.Generic;
8
+using System.Linq;
9
+
10
+namespace ProRestaurant.Repository.Restaurants
11
+{
12
+    public class MenuOptionRepository : IMenuOptionRepository
13
+    {
14
+        private readonly DBContext dBContext;
15
+
16
+        public MenuOptionRepository(DBContext _dBContext)
17
+        {
18
+            dBContext = _dBContext;
19
+        }
20
+
21
+        public void Delete(MenuOption Option)
22
+        {
23
+            if (Option.Options != null)
24
+            {
25
+                foreach (var item in Option.Options)
26
+                {
27
+                    DeleteItem(item);
28
+                }
29
+            }
30
+
31
+            dBContext.MenuOptions.Remove(Option);
32
+            Save();
33
+        }
34
+
35
+        public void DeleteItem(int id)
36
+        {
37
+            var item = dBContext.MenuOptionItems.Where(i => i.Id == id).FirstOrDefault();
38
+            dBContext.MenuOptionItems.Remove(item);
39
+            Save();
40
+        }
41
+
42
+        public void DeleteItem(MenuOptionItem item)
43
+        {
44
+            dBContext.MenuOptionItems.Remove(item);
45
+            Save();
46
+        }
47
+
48
+        public MenuOption GetMenuOption(int id)
49
+        {
50
+            var option = dBContext.MenuOptions.Where(m => m.Id == id).FirstOrDefault();
51
+
52
+            if (option == null)
53
+            {
54
+                option = new MenuOption()
55
+                {
56
+                    OptionType = OptionType.Single,
57
+                    IsBasePrice = false,
58
+                    Options = new List<MenuOptionItem>(),
59
+                    CategoryDescription = "All"
60
+                };
61
+            }
62
+            else
63
+            {
64
+                option.Options = dBContext.MenuOptionItems.Where(m => m.MenuOption == option).ToList();
65
+                if (option.CategoryId > 0)
66
+                    option.CategoryDescription = dBContext.MenuCategories.Where(m => m.Id == option.CategoryId).FirstOrDefault().Description;
67
+                else
68
+                    option.CategoryDescription = "All";
69
+            }
70
+
71
+            return option;
72
+        }
73
+
74
+        public List<OptionTypeContainer> GetOptionTypes()
75
+        {
76
+            //TODO: hard coded for now, will need to find solution.
77
+            var options = new List<OptionTypeContainer>
78
+            {
79
+                new OptionTypeContainer() { Id = 0, Description = "Single" },
80
+                new OptionTypeContainer() { Id = 1, Description = "Single Required" },
81
+                new OptionTypeContainer() { Id = 2, Description = "Multiple" },
82
+                new OptionTypeContainer() { Id = 3, Description = "Multiple Limit" }
83
+            };
84
+
85
+            return options;
86
+        }
87
+
88
+        public List<MenuOption> GetRestaurantMenuOptions(int restaurantId)
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
93
+                           orderby o.Rank
94
+                           select o).ToList();
95
+
96
+            foreach (var option in options)
97
+            {
98
+                switch (option.OptionType)
99
+                {
100
+                    case OptionType.MultipleLimit:
101
+                        option.OptionTypeDescription = "Multiple Limit";
102
+                        break;
103
+                    case OptionType.SingleRequired:
104
+                        option.OptionTypeDescription = "Single Required";
105
+                        break;
106
+                    default:
107
+                        option.OptionTypeDescription = option.OptionType.ToString();
108
+                        break;
109
+                }
110
+
111
+                if (option.CategoryId > 0)
112
+                    option.CategoryDescription = dBContext.MenuCategories.Where(m => m.Id == option.CategoryId).FirstOrDefault().Description;
113
+                else
114
+                    option.CategoryDescription = "All";
115
+            }
116
+
117
+            return options;
118
+        }
119
+
120
+        public void Insert(MenuOption Option)
121
+        {
122
+            dBContext.Add(Option);
123
+            Save();
124
+        }
125
+
126
+        public void Save()
127
+        {
128
+            dBContext.SaveChanges();
129
+        }
130
+
131
+        public void Update(MenuOption Option)
132
+        {
133
+            dBContext.Entry(Option).State = EntityState.Modified;
134
+            foreach (var opt in Option.Options)
135
+            {
136
+                if (opt.Id > 0)
137
+                {
138
+                    dBContext.Entry(opt).State = EntityState.Modified;
139
+                }
140
+                else
141
+                {
142
+                    dBContext.Add(opt);
143
+                }
144
+            }
145
+
146
+            Save();
147
+        }
148
+    }
149
+}

+ 7
- 0
ProRestaurant/Startup.cs Прегледај датотеку

@@ -15,6 +15,7 @@ using Microsoft.Extensions.DependencyInjection;
15 15
 using Microsoft.Extensions.Logging;
16 16
 using Microsoft.Extensions.Options;
17 17
 using Microsoft.IdentityModel.Tokens;
18
+using Newtonsoft.Json;
18 19
 using ProRestaurant.Classes;
19 20
 using ProRestaurant.DBContexts;
20 21
 using ProRestaurant.Repository.Accounts;
@@ -40,6 +41,9 @@ namespace ProRestaurant
40 41
                        .AllowAnyHeader();
41 42
             }));
42 43
             services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
44
+            services.AddMvc().AddJsonOptions(options => {
45
+                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
46
+            });
43 47
 
44 48
             #region Authentication Setup
45 49
             // configure strongly typed settings objects
@@ -78,6 +82,9 @@ namespace ProRestaurant
78 82
             services.AddTransient<IRestaurantRepository, RestaurantRepository>();
79 83
             services.AddTransient<IUserRepository, UserRepository>();
80 84
             services.AddTransient<IMenuCategoryRepository, MenuCategoryRepository>();
85
+            services.AddTransient<IMenuOptionRepository, MenuOptionRepository>();
86
+            services.AddTransient<IMenuItemRepository, MenuItemRepository>();
87
+            services.AddTransient<IMenuRepository, MenuRepository>();
81 88
 
82 89
             services.Configure<MvcOptions>(options =>
83 90
             {

BIN
ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.dll Прегледај датотеку


BIN
ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.pdb Прегледај датотеку


+ 1
- 1
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csproj.CoreCompileInputs.cache Прегледај датотеку

@@ -1 +1 @@
1
-7ee9c31cc58d25ebc38120ba0960c1c57a6e9ec2
1
+6449f93053b2ae76a77e4da47929d5cb895df3c6

BIN
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csprojAssemblyReference.cache Прегледај датотеку


BIN
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.dll Прегледај датотеку


BIN
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.pdb Прегледај датотеку


Loading…
Откажи
Сачувај