Procházet zdrojové kódy

got axios working

master
George Williams před 4 roky
rodič
revize
6ef60d34ac
31 změnil soubory, kde provedl 868 přidání a 299 odebrání
  1. binární
      .vs/ProRestaurant/DesignTimeBuild/.dtbcache.v2
  2. 2
    3
      .vs/ProRestaurant/config/applicationhost.config
  3. binární
      .vs/ProRestaurant/v16/.suo
  4. 24
    0
      ProRestaurant/Classes/CommonFunctions.cs
  5. 10
    0
      ProRestaurant/Containers/UserContainer.cs
  6. 6
    0
      ProRestaurant/Controllers/Accounts/UserController.cs
  7. 2
    3
      ProRestaurant/DBContexts/DBContext.cs
  8. 0
    138
      ProRestaurant/Migrations/20200522120517_migration001.Designer.cs
  9. 0
    112
      ProRestaurant/Migrations/20200522120517_migration001.cs
  10. 286
    0
      ProRestaurant/Migrations/20200526094220_initialCreate.Designer.cs
  11. 242
    0
      ProRestaurant/Migrations/20200526094220_initialCreate.cs
  12. 148
    0
      ProRestaurant/Migrations/DBContextModelSnapshot.cs
  13. 22
    0
      ProRestaurant/Models/BaseObject.cs
  14. 13
    0
      ProRestaurant/Models/Restaurants/MenuCategory.cs
  15. 11
    15
      ProRestaurant/Models/Restaurants/MenuItem.cs
  16. 7
    7
      ProRestaurant/Properties/launchSettings.json
  17. 3
    1
      ProRestaurant/Repository/Accounts/IUserRepository.cs
  18. 49
    2
      ProRestaurant/Repository/Accounts/UserRepository.cs
  19. 7
    0
      ProRestaurant/Startup.cs
  20. binární
      ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.dll
  21. binární
      ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.pdb
  22. 7
    7
      ProRestaurant/bin/Debug/netcoreapp2.2/Properties/launchSettings.json
  23. binární
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.assets.cache
  24. 1
    1
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csproj.CoreCompileInputs.cache
  25. 18
    0
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csproj.FileListAbsolute.txt
  26. binární
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csprojAssemblyReference.cache
  27. binární
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.dll
  28. binární
      ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.pdb
  29. 5
    5
      ProRestaurant/obj/ProRestaurant.csproj.nuget.dgspec.json
  30. 3
    3
      ProRestaurant/obj/project.assets.json
  31. 2
    2
      ProRestaurant/obj/project.nuget.cache

binární
.vs/ProRestaurant/DesignTimeBuild/.dtbcache.v2 Zobrazit soubor


+ 2
- 3
.vs/ProRestaurant/config/applicationhost.config Zobrazit soubor

@@ -1,4 +1,4 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
1
+<?xml version="1.0" encoding="UTF-8"?>
2 2
 <!--
3 3
 
4 4
     IIS configuration sections.
@@ -157,11 +157,10 @@
157 157
       </site>
158 158
       <site name="ProRestaurant" id="2">
159 159
         <application path="/" applicationPool="ProRestaurant AppPool">
160
-          <virtualDirectory path="/" physicalPath="C:\Work\Development\ProRestaurant\ProResturantAPI\ProRestaurant\ProRestaurant" />
160
+          <virtualDirectory path="/" physicalPath="C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant" />
161 161
         </application>
162 162
         <bindings>
163 163
           <binding protocol="http" bindingInformation="*:58847:localhost" />
164
-          <binding protocol="https" bindingInformation="*:44376:localhost" />
165 164
         </bindings>
166 165
       </site>
167 166
       <siteDefaults>

binární
.vs/ProRestaurant/v16/.suo Zobrazit soubor


+ 24
- 0
ProRestaurant/Classes/CommonFunctions.cs Zobrazit soubor

@@ -0,0 +1,24 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Security.Cryptography;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+
8
+namespace ProRestaurant.Classes
9
+{
10
+    public class CommonFunctions
11
+    {
12
+        public static string GetHashSHA256(string text)
13
+        {            
14
+            SHA256Managed crypt = new SHA256Managed();
15
+            string hash = string.Empty;
16
+            byte[] crypto = crypt.ComputeHash(Encoding.UTF8.GetBytes(text), 0, Encoding.UTF8.GetByteCount(text));
17
+            foreach (byte bit in crypto)
18
+            {
19
+                hash += bit.ToString("x2");
20
+            }
21
+            return hash;
22
+        }
23
+    }
24
+}

+ 10
- 0
ProRestaurant/Containers/UserContainer.cs Zobrazit soubor

@@ -0,0 +1,10 @@
1
+using ProRestaurant.Models.Accounts;
2
+
3
+namespace ProRestaurant.Containers
4
+{
5
+    public class UserContainer 
6
+    {
7
+        public string ResultString { get; set; }
8
+        public User user { get; set; }
9
+    }
10
+}

+ 6
- 0
ProRestaurant/Controllers/Accounts/UserController.cs Zobrazit soubor

@@ -29,6 +29,12 @@ namespace ProRestaurant.Controllers.Accounts
29 29
             var user = userRepository.GetUser(u => u.Id == id);
30 30
             return new OkObjectResult(user);
31 31
         }
32
+
33
+        [HttpGet("Login/{username}/{password}")]
34
+        public IActionResult Login(string username, string password)
35
+        {
36
+            return new OkObjectResult(userRepository.Login(username, password));
37
+        }
32 38
         
33 39
         [HttpPost]
34 40
         public IActionResult Post([FromBody] User user)

+ 2
- 3
ProRestaurant/DBContexts/DBContext.cs Zobrazit soubor

@@ -3,11 +3,8 @@ using Npgsql;
3 3
 using ProRestaurant.Models;
4 4
 using ProRestaurant.Models.Accounts;
5 5
 using ProRestaurant.Models.Restaurants;
6
-using System;
7
-using System.Collections.Generic;
8 6
 using System.Data.SqlClient;
9 7
 using System.Linq;
10
-using System.Threading.Tasks;
11 8
 
12 9
 namespace ProRestaurant.DBContexts
13 10
 {
@@ -42,6 +39,8 @@ namespace ProRestaurant.DBContexts
42 39
         #region Restaurants
43 40
         public DbSet<Restaurant> Restaurants { get; set; }
44 41
         public DbSet<TradingHours> TradingHours { get; set; }
42
+        public DbSet<MenuCategory> MenuCategories { get; set; }
43
+        public DbSet<MenuItem> MenuItems { get; set; }
45 44
         #endregion 
46 45
 
47 46
         public override int SaveChanges()

+ 0
- 138
ProRestaurant/Migrations/20200522120517_migration001.Designer.cs Zobrazit soubor

@@ -1,138 +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("20200522120517_migration001")]
14
-    partial class migration001
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<DateTime>("Modified");
33
-
34
-                    b.Property<string>("ModifiedBy");
35
-
36
-                    b.Property<string>("Photo");
37
-
38
-                    b.Property<string>("RegistrationNumber");
39
-
40
-                    b.Property<int>("UserId");
41
-
42
-                    b.HasKey("Id");
43
-
44
-                    b.HasIndex("UserId")
45
-                        .IsUnique();
46
-
47
-                    b.ToTable("DriverDetails");
48
-                });
49
-
50
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.User", b =>
51
-                {
52
-                    b.Property<int>("Id")
53
-                        .ValueGeneratedOnAdd()
54
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
55
-
56
-                    b.Property<string>("Cellphone");
57
-
58
-                    b.Property<DateTime>("Created");
59
-
60
-                    b.Property<string>("EmailAddress");
61
-
62
-                    b.Property<string>("FirstName");
63
-
64
-                    b.Property<DateTime>("Modified");
65
-
66
-                    b.Property<string>("ModifiedBy");
67
-
68
-                    b.Property<string>("Password");
69
-
70
-                    b.Property<string>("Surname");
71
-
72
-                    b.HasKey("Id");
73
-
74
-                    b.ToTable("Users");
75
-                });
76
-
77
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
78
-                {
79
-                    b.Property<int>("Id")
80
-                        .ValueGeneratedOnAdd()
81
-                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
82
-
83
-                    b.Property<string>("City");
84
-
85
-                    b.Property<string>("ComplexName");
86
-
87
-                    b.Property<string>("Country");
88
-
89
-                    b.Property<DateTime>("Created");
90
-
91
-                    b.Property<decimal>("Latitude");
92
-
93
-                    b.Property<decimal>("Longitude");
94
-
95
-                    b.Property<DateTime>("Modified");
96
-
97
-                    b.Property<string>("ModifiedBy");
98
-
99
-                    b.Property<string>("PostalCode");
100
-
101
-                    b.Property<string>("Provice");
102
-
103
-                    b.Property<string>("SteetNumber");
104
-
105
-                    b.Property<string>("StreetName");
106
-
107
-                    b.Property<string>("Suburb");
108
-
109
-                    b.Property<string>("UnitNumber");
110
-
111
-                    b.Property<int>("UserId");
112
-
113
-                    b.HasKey("Id");
114
-
115
-                    b.HasIndex("UserId");
116
-
117
-                    b.ToTable("UserAddresses");
118
-                });
119
-
120
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
121
-                {
122
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
123
-                        .WithOne("DriverDetails")
124
-                        .HasForeignKey("ProRestaurant.Models.Accounts.DriverDetail", "UserId")
125
-                        .OnDelete(DeleteBehavior.Cascade);
126
-                });
127
-
128
-            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
129
-                {
130
-                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
131
-                        .WithMany()
132
-                        .HasForeignKey("UserId")
133
-                        .OnDelete(DeleteBehavior.Cascade);
134
-                });
135
-#pragma warning restore 612, 618
136
-        }
137
-    }
138
-}

+ 0
- 112
ProRestaurant/Migrations/20200522120517_migration001.cs Zobrazit soubor

@@ -1,112 +0,0 @@
1
-using System;
2
-using Microsoft.EntityFrameworkCore.Metadata;
3
-using Microsoft.EntityFrameworkCore.Migrations;
4
-
5
-namespace ProRestaurant.Migrations
6
-{
7
-    public partial class migration001 : Migration
8
-    {
9
-        protected override void Up(MigrationBuilder migrationBuilder)
10
-        {
11
-            migrationBuilder.CreateTable(
12
-                name: "Users",
13
-                columns: table => new
14
-                {
15
-                    Id = table.Column<int>(nullable: false)
16
-                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
17
-                    Created = table.Column<DateTime>(nullable: false),
18
-                    Modified = table.Column<DateTime>(nullable: false),
19
-                    ModifiedBy = table.Column<string>(nullable: true),
20
-                    EmailAddress = table.Column<string>(nullable: true),
21
-                    Password = table.Column<string>(nullable: true),
22
-                    FirstName = table.Column<string>(nullable: true),
23
-                    Surname = table.Column<string>(nullable: true),
24
-                    Cellphone = table.Column<string>(nullable: true)
25
-                },
26
-                constraints: table =>
27
-                {
28
-                    table.PrimaryKey("PK_Users", x => x.Id);
29
-                });
30
-
31
-            migrationBuilder.CreateTable(
32
-                name: "DriverDetails",
33
-                columns: table => new
34
-                {
35
-                    Id = table.Column<int>(nullable: false)
36
-                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
37
-                    Created = table.Column<DateTime>(nullable: false),
38
-                    Modified = table.Column<DateTime>(nullable: false),
39
-                    ModifiedBy = table.Column<string>(nullable: true),
40
-                    UserId = table.Column<int>(nullable: false),
41
-                    Photo = table.Column<string>(nullable: true),
42
-                    RegistrationNumber = table.Column<string>(nullable: true)
43
-                },
44
-                constraints: table =>
45
-                {
46
-                    table.PrimaryKey("PK_DriverDetails", x => x.Id);
47
-                    table.ForeignKey(
48
-                        name: "FK_DriverDetails_Users_UserId",
49
-                        column: x => x.UserId,
50
-                        principalTable: "Users",
51
-                        principalColumn: "Id",
52
-                        onDelete: ReferentialAction.Cascade);
53
-                });
54
-
55
-            migrationBuilder.CreateTable(
56
-                name: "UserAddresses",
57
-                columns: table => new
58
-                {
59
-                    Id = table.Column<int>(nullable: false)
60
-                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
61
-                    Created = table.Column<DateTime>(nullable: false),
62
-                    Modified = table.Column<DateTime>(nullable: false),
63
-                    ModifiedBy = table.Column<string>(nullable: true),
64
-                    UserId = table.Column<int>(nullable: false),
65
-                    Latitude = table.Column<decimal>(nullable: false),
66
-                    Longitude = table.Column<decimal>(nullable: false),
67
-                    UnitNumber = table.Column<string>(nullable: true),
68
-                    ComplexName = table.Column<string>(nullable: true),
69
-                    SteetNumber = table.Column<string>(nullable: true),
70
-                    StreetName = table.Column<string>(nullable: true),
71
-                    Suburb = table.Column<string>(nullable: true),
72
-                    City = table.Column<string>(nullable: true),
73
-                    Provice = table.Column<string>(nullable: true),
74
-                    Country = table.Column<string>(nullable: true),
75
-                    PostalCode = table.Column<string>(nullable: true)
76
-                },
77
-                constraints: table =>
78
-                {
79
-                    table.PrimaryKey("PK_UserAddresses", x => x.Id);
80
-                    table.ForeignKey(
81
-                        name: "FK_UserAddresses_Users_UserId",
82
-                        column: x => x.UserId,
83
-                        principalTable: "Users",
84
-                        principalColumn: "Id",
85
-                        onDelete: ReferentialAction.Cascade);
86
-                });
87
-
88
-            migrationBuilder.CreateIndex(
89
-                name: "IX_DriverDetails_UserId",
90
-                table: "DriverDetails",
91
-                column: "UserId",
92
-                unique: true);
93
-
94
-            migrationBuilder.CreateIndex(
95
-                name: "IX_UserAddresses_UserId",
96
-                table: "UserAddresses",
97
-                column: "UserId");
98
-        }
99
-
100
-        protected override void Down(MigrationBuilder migrationBuilder)
101
-        {
102
-            migrationBuilder.DropTable(
103
-                name: "DriverDetails");
104
-
105
-            migrationBuilder.DropTable(
106
-                name: "UserAddresses");
107
-
108
-            migrationBuilder.DropTable(
109
-                name: "Users");
110
-        }
111
-    }
112
-}

+ 286
- 0
ProRestaurant/Migrations/20200526094220_initialCreate.Designer.cs Zobrazit soubor

@@ -0,0 +1,286 @@
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("20200526094220_initialCreate")]
14
+    partial class initialCreate
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.HasKey("Id");
77
+
78
+                    b.ToTable("Users");
79
+                });
80
+
81
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
82
+                {
83
+                    b.Property<int>("Id")
84
+                        .ValueGeneratedOnAdd()
85
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
86
+
87
+                    b.Property<string>("City");
88
+
89
+                    b.Property<string>("ComplexName");
90
+
91
+                    b.Property<string>("Country");
92
+
93
+                    b.Property<DateTime>("Created");
94
+
95
+                    b.Property<bool>("IsDeleted");
96
+
97
+                    b.Property<decimal>("Latitude");
98
+
99
+                    b.Property<decimal>("Longitude");
100
+
101
+                    b.Property<DateTime>("Modified");
102
+
103
+                    b.Property<string>("ModifiedBy");
104
+
105
+                    b.Property<string>("PostalCode");
106
+
107
+                    b.Property<string>("Provice");
108
+
109
+                    b.Property<string>("SteetNumber");
110
+
111
+                    b.Property<string>("StreetName");
112
+
113
+                    b.Property<string>("Suburb");
114
+
115
+                    b.Property<string>("UnitNumber");
116
+
117
+                    b.Property<int>("UserId");
118
+
119
+                    b.HasKey("Id");
120
+
121
+                    b.HasIndex("UserId");
122
+
123
+                    b.ToTable("UserAddresses");
124
+                });
125
+
126
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
127
+                {
128
+                    b.Property<int>("Id")
129
+                        .ValueGeneratedOnAdd()
130
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
131
+
132
+                    b.Property<DateTime>("Created");
133
+
134
+                    b.Property<string>("Description");
135
+
136
+                    b.Property<bool>("IsDeleted");
137
+
138
+                    b.Property<DateTime>("Modified");
139
+
140
+                    b.Property<string>("ModifiedBy");
141
+
142
+                    b.Property<int>("RestaurantId");
143
+
144
+                    b.HasKey("Id");
145
+
146
+                    b.HasIndex("RestaurantId");
147
+
148
+                    b.ToTable("MenuCategories");
149
+                });
150
+
151
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
152
+                {
153
+                    b.Property<int>("Id")
154
+                        .ValueGeneratedOnAdd()
155
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
156
+
157
+                    b.Property<int>("CategoryId");
158
+
159
+                    b.Property<DateTime>("Created");
160
+
161
+                    b.Property<string>("Description");
162
+
163
+                    b.Property<string>("Image");
164
+
165
+                    b.Property<bool>("IsDeleted");
166
+
167
+                    b.Property<DateTime>("Modified");
168
+
169
+                    b.Property<string>("ModifiedBy");
170
+
171
+                    b.Property<decimal>("Price");
172
+
173
+                    b.Property<int>("RestaurantId");
174
+
175
+                    b.HasKey("Id");
176
+
177
+                    b.HasIndex("RestaurantId");
178
+
179
+                    b.ToTable("MenuItems");
180
+                });
181
+
182
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
183
+                {
184
+                    b.Property<int>("Id")
185
+                        .ValueGeneratedOnAdd()
186
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
187
+
188
+                    b.Property<bool>("Chain");
189
+
190
+                    b.Property<DateTime>("Created");
191
+
192
+                    b.Property<decimal>("DeliveryFee");
193
+
194
+                    b.Property<decimal>("DeliveryRadius");
195
+
196
+                    b.Property<bool>("IsDeleted");
197
+
198
+                    b.Property<string>("Location");
199
+
200
+                    b.Property<string>("Logo");
201
+
202
+                    b.Property<string>("MethodsOfPayment");
203
+
204
+                    b.Property<DateTime>("Modified");
205
+
206
+                    b.Property<string>("ModifiedBy");
207
+
208
+                    b.Property<string>("Name");
209
+
210
+                    b.HasKey("Id");
211
+
212
+                    b.ToTable("Restaurants");
213
+                });
214
+
215
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
216
+                {
217
+                    b.Property<int>("Id")
218
+                        .ValueGeneratedOnAdd()
219
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
220
+
221
+                    b.Property<DateTime>("ClosingTime");
222
+
223
+                    b.Property<DateTime>("Created");
224
+
225
+                    b.Property<string>("Description");
226
+
227
+                    b.Property<bool>("IsDeleted");
228
+
229
+                    b.Property<DateTime>("Modified");
230
+
231
+                    b.Property<string>("ModifiedBy");
232
+
233
+                    b.Property<DateTime>("OpeningTime");
234
+
235
+                    b.Property<int>("RestaurantId");
236
+
237
+                    b.HasKey("Id");
238
+
239
+                    b.HasIndex("RestaurantId");
240
+
241
+                    b.ToTable("TradingHours");
242
+                });
243
+
244
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
245
+                {
246
+                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
247
+                        .WithOne("DriverDetails")
248
+                        .HasForeignKey("ProRestaurant.Models.Accounts.DriverDetail", "UserId")
249
+                        .OnDelete(DeleteBehavior.Cascade);
250
+                });
251
+
252
+            modelBuilder.Entity("ProRestaurant.Models.Accounts.UserAddress", b =>
253
+                {
254
+                    b.HasOne("ProRestaurant.Models.Accounts.User", "User")
255
+                        .WithMany()
256
+                        .HasForeignKey("UserId")
257
+                        .OnDelete(DeleteBehavior.Cascade);
258
+                });
259
+
260
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
261
+                {
262
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
263
+                        .WithMany()
264
+                        .HasForeignKey("RestaurantId")
265
+                        .OnDelete(DeleteBehavior.Cascade);
266
+                });
267
+
268
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
269
+                {
270
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
271
+                        .WithMany()
272
+                        .HasForeignKey("RestaurantId")
273
+                        .OnDelete(DeleteBehavior.Cascade);
274
+                });
275
+
276
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
277
+                {
278
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
279
+                        .WithMany("TradingHours")
280
+                        .HasForeignKey("RestaurantId")
281
+                        .OnDelete(DeleteBehavior.Cascade);
282
+                });
283
+#pragma warning restore 612, 618
284
+        }
285
+    }
286
+}

+ 242
- 0
ProRestaurant/Migrations/20200526094220_initialCreate.cs Zobrazit soubor

@@ -0,0 +1,242 @@
1
+using System;
2
+using Microsoft.EntityFrameworkCore.Metadata;
3
+using Microsoft.EntityFrameworkCore.Migrations;
4
+
5
+namespace ProRestaurant.Migrations
6
+{
7
+    public partial class initialCreate : Migration
8
+    {
9
+        protected override void Up(MigrationBuilder migrationBuilder)
10
+        {
11
+            migrationBuilder.CreateTable(
12
+                name: "Restaurants",
13
+                columns: table => new
14
+                {
15
+                    Id = table.Column<int>(nullable: false)
16
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
17
+                    Created = table.Column<DateTime>(nullable: false),
18
+                    Modified = table.Column<DateTime>(nullable: false),
19
+                    ModifiedBy = table.Column<string>(nullable: true),
20
+                    IsDeleted = table.Column<bool>(nullable: false),
21
+                    Name = table.Column<string>(nullable: true),
22
+                    Location = table.Column<string>(nullable: true),
23
+                    Logo = table.Column<string>(nullable: true),
24
+                    Chain = table.Column<bool>(nullable: false),
25
+                    DeliveryFee = table.Column<decimal>(nullable: false),
26
+                    DeliveryRadius = table.Column<decimal>(nullable: false),
27
+                    MethodsOfPayment = table.Column<string>(nullable: true)
28
+                },
29
+                constraints: table =>
30
+                {
31
+                    table.PrimaryKey("PK_Restaurants", x => x.Id);
32
+                });
33
+
34
+            migrationBuilder.CreateTable(
35
+                name: "Users",
36
+                columns: table => new
37
+                {
38
+                    Id = table.Column<int>(nullable: false)
39
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
40
+                    Created = table.Column<DateTime>(nullable: false),
41
+                    Modified = table.Column<DateTime>(nullable: false),
42
+                    ModifiedBy = table.Column<string>(nullable: true),
43
+                    IsDeleted = table.Column<bool>(nullable: false),
44
+                    EmailAddress = table.Column<string>(nullable: true),
45
+                    Password = table.Column<string>(nullable: true),
46
+                    FirstName = table.Column<string>(nullable: true),
47
+                    Surname = table.Column<string>(nullable: true),
48
+                    Cellphone = table.Column<string>(nullable: true)
49
+                },
50
+                constraints: table =>
51
+                {
52
+                    table.PrimaryKey("PK_Users", x => x.Id);
53
+                });
54
+
55
+            migrationBuilder.CreateTable(
56
+                name: "MenuCategories",
57
+                columns: table => new
58
+                {
59
+                    Id = table.Column<int>(nullable: false)
60
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
61
+                    Created = table.Column<DateTime>(nullable: false),
62
+                    Modified = table.Column<DateTime>(nullable: false),
63
+                    ModifiedBy = table.Column<string>(nullable: true),
64
+                    IsDeleted = table.Column<bool>(nullable: false),
65
+                    RestaurantId = table.Column<int>(nullable: false),
66
+                    Description = table.Column<string>(nullable: true)
67
+                },
68
+                constraints: table =>
69
+                {
70
+                    table.PrimaryKey("PK_MenuCategories", x => x.Id);
71
+                    table.ForeignKey(
72
+                        name: "FK_MenuCategories_Restaurants_RestaurantId",
73
+                        column: x => x.RestaurantId,
74
+                        principalTable: "Restaurants",
75
+                        principalColumn: "Id",
76
+                        onDelete: ReferentialAction.Cascade);
77
+                });
78
+
79
+            migrationBuilder.CreateTable(
80
+                name: "MenuItems",
81
+                columns: table => new
82
+                {
83
+                    Id = table.Column<int>(nullable: false)
84
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
85
+                    Created = table.Column<DateTime>(nullable: false),
86
+                    Modified = table.Column<DateTime>(nullable: false),
87
+                    ModifiedBy = table.Column<string>(nullable: true),
88
+                    IsDeleted = table.Column<bool>(nullable: false),
89
+                    RestaurantId = table.Column<int>(nullable: false),
90
+                    CategoryId = table.Column<int>(nullable: false),
91
+                    Image = table.Column<string>(nullable: true),
92
+                    Description = table.Column<string>(nullable: true),
93
+                    Price = table.Column<decimal>(nullable: false)
94
+                },
95
+                constraints: table =>
96
+                {
97
+                    table.PrimaryKey("PK_MenuItems", x => x.Id);
98
+                    table.ForeignKey(
99
+                        name: "FK_MenuItems_Restaurants_RestaurantId",
100
+                        column: x => x.RestaurantId,
101
+                        principalTable: "Restaurants",
102
+                        principalColumn: "Id",
103
+                        onDelete: ReferentialAction.Cascade);
104
+                });
105
+
106
+            migrationBuilder.CreateTable(
107
+                name: "TradingHours",
108
+                columns: table => new
109
+                {
110
+                    Id = table.Column<int>(nullable: false)
111
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
112
+                    Created = table.Column<DateTime>(nullable: false),
113
+                    Modified = table.Column<DateTime>(nullable: false),
114
+                    ModifiedBy = table.Column<string>(nullable: true),
115
+                    IsDeleted = table.Column<bool>(nullable: false),
116
+                    RestaurantId = table.Column<int>(nullable: false),
117
+                    Description = table.Column<string>(nullable: true),
118
+                    OpeningTime = table.Column<DateTime>(nullable: false),
119
+                    ClosingTime = table.Column<DateTime>(nullable: false)
120
+                },
121
+                constraints: table =>
122
+                {
123
+                    table.PrimaryKey("PK_TradingHours", x => x.Id);
124
+                    table.ForeignKey(
125
+                        name: "FK_TradingHours_Restaurants_RestaurantId",
126
+                        column: x => x.RestaurantId,
127
+                        principalTable: "Restaurants",
128
+                        principalColumn: "Id",
129
+                        onDelete: ReferentialAction.Cascade);
130
+                });
131
+
132
+            migrationBuilder.CreateTable(
133
+                name: "DriverDetails",
134
+                columns: table => new
135
+                {
136
+                    Id = table.Column<int>(nullable: false)
137
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
138
+                    Created = table.Column<DateTime>(nullable: false),
139
+                    Modified = table.Column<DateTime>(nullable: false),
140
+                    ModifiedBy = table.Column<string>(nullable: true),
141
+                    IsDeleted = table.Column<bool>(nullable: false),
142
+                    UserId = table.Column<int>(nullable: false),
143
+                    Photo = table.Column<string>(nullable: true),
144
+                    RegistrationNumber = table.Column<string>(nullable: true)
145
+                },
146
+                constraints: table =>
147
+                {
148
+                    table.PrimaryKey("PK_DriverDetails", x => x.Id);
149
+                    table.ForeignKey(
150
+                        name: "FK_DriverDetails_Users_UserId",
151
+                        column: x => x.UserId,
152
+                        principalTable: "Users",
153
+                        principalColumn: "Id",
154
+                        onDelete: ReferentialAction.Cascade);
155
+                });
156
+
157
+            migrationBuilder.CreateTable(
158
+                name: "UserAddresses",
159
+                columns: table => new
160
+                {
161
+                    Id = table.Column<int>(nullable: false)
162
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
163
+                    Created = table.Column<DateTime>(nullable: false),
164
+                    Modified = table.Column<DateTime>(nullable: false),
165
+                    ModifiedBy = table.Column<string>(nullable: true),
166
+                    IsDeleted = table.Column<bool>(nullable: false),
167
+                    UserId = table.Column<int>(nullable: false),
168
+                    Latitude = table.Column<decimal>(nullable: false),
169
+                    Longitude = table.Column<decimal>(nullable: false),
170
+                    UnitNumber = table.Column<string>(nullable: true),
171
+                    ComplexName = table.Column<string>(nullable: true),
172
+                    SteetNumber = table.Column<string>(nullable: true),
173
+                    StreetName = table.Column<string>(nullable: true),
174
+                    Suburb = table.Column<string>(nullable: true),
175
+                    City = table.Column<string>(nullable: true),
176
+                    Provice = table.Column<string>(nullable: true),
177
+                    Country = table.Column<string>(nullable: true),
178
+                    PostalCode = table.Column<string>(nullable: true)
179
+                },
180
+                constraints: table =>
181
+                {
182
+                    table.PrimaryKey("PK_UserAddresses", x => x.Id);
183
+                    table.ForeignKey(
184
+                        name: "FK_UserAddresses_Users_UserId",
185
+                        column: x => x.UserId,
186
+                        principalTable: "Users",
187
+                        principalColumn: "Id",
188
+                        onDelete: ReferentialAction.Cascade);
189
+                });
190
+
191
+            migrationBuilder.CreateIndex(
192
+                name: "IX_DriverDetails_UserId",
193
+                table: "DriverDetails",
194
+                column: "UserId",
195
+                unique: true);
196
+
197
+            migrationBuilder.CreateIndex(
198
+                name: "IX_MenuCategories_RestaurantId",
199
+                table: "MenuCategories",
200
+                column: "RestaurantId");
201
+
202
+            migrationBuilder.CreateIndex(
203
+                name: "IX_MenuItems_RestaurantId",
204
+                table: "MenuItems",
205
+                column: "RestaurantId");
206
+
207
+            migrationBuilder.CreateIndex(
208
+                name: "IX_TradingHours_RestaurantId",
209
+                table: "TradingHours",
210
+                column: "RestaurantId");
211
+
212
+            migrationBuilder.CreateIndex(
213
+                name: "IX_UserAddresses_UserId",
214
+                table: "UserAddresses",
215
+                column: "UserId");
216
+        }
217
+
218
+        protected override void Down(MigrationBuilder migrationBuilder)
219
+        {
220
+            migrationBuilder.DropTable(
221
+                name: "DriverDetails");
222
+
223
+            migrationBuilder.DropTable(
224
+                name: "MenuCategories");
225
+
226
+            migrationBuilder.DropTable(
227
+                name: "MenuItems");
228
+
229
+            migrationBuilder.DropTable(
230
+                name: "TradingHours");
231
+
232
+            migrationBuilder.DropTable(
233
+                name: "UserAddresses");
234
+
235
+            migrationBuilder.DropTable(
236
+                name: "Restaurants");
237
+
238
+            migrationBuilder.DropTable(
239
+                name: "Users");
240
+        }
241
+    }
242
+}

+ 148
- 0
ProRestaurant/Migrations/DBContextModelSnapshot.cs Zobrazit soubor

@@ -27,6 +27,8 @@ namespace ProRestaurant.Migrations
27 27
 
28 28
                     b.Property<DateTime>("Created");
29 29
 
30
+                    b.Property<bool>("IsDeleted");
31
+
30 32
                     b.Property<DateTime>("Modified");
31 33
 
32 34
                     b.Property<string>("ModifiedBy");
@@ -59,6 +61,8 @@ namespace ProRestaurant.Migrations
59 61
 
60 62
                     b.Property<string>("FirstName");
61 63
 
64
+                    b.Property<bool>("IsDeleted");
65
+
62 66
                     b.Property<DateTime>("Modified");
63 67
 
64 68
                     b.Property<string>("ModifiedBy");
@@ -86,6 +90,8 @@ namespace ProRestaurant.Migrations
86 90
 
87 91
                     b.Property<DateTime>("Created");
88 92
 
93
+                    b.Property<bool>("IsDeleted");
94
+
89 95
                     b.Property<decimal>("Latitude");
90 96
 
91 97
                     b.Property<decimal>("Longitude");
@@ -115,6 +121,124 @@ namespace ProRestaurant.Migrations
115 121
                     b.ToTable("UserAddresses");
116 122
                 });
117 123
 
124
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
125
+                {
126
+                    b.Property<int>("Id")
127
+                        .ValueGeneratedOnAdd()
128
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
129
+
130
+                    b.Property<DateTime>("Created");
131
+
132
+                    b.Property<string>("Description");
133
+
134
+                    b.Property<bool>("IsDeleted");
135
+
136
+                    b.Property<DateTime>("Modified");
137
+
138
+                    b.Property<string>("ModifiedBy");
139
+
140
+                    b.Property<int>("RestaurantId");
141
+
142
+                    b.HasKey("Id");
143
+
144
+                    b.HasIndex("RestaurantId");
145
+
146
+                    b.ToTable("MenuCategories");
147
+                });
148
+
149
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
150
+                {
151
+                    b.Property<int>("Id")
152
+                        .ValueGeneratedOnAdd()
153
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
154
+
155
+                    b.Property<int>("CategoryId");
156
+
157
+                    b.Property<DateTime>("Created");
158
+
159
+                    b.Property<string>("Description");
160
+
161
+                    b.Property<string>("Image");
162
+
163
+                    b.Property<bool>("IsDeleted");
164
+
165
+                    b.Property<DateTime>("Modified");
166
+
167
+                    b.Property<string>("ModifiedBy");
168
+
169
+                    b.Property<decimal>("Price");
170
+
171
+                    b.Property<int>("RestaurantId");
172
+
173
+                    b.HasKey("Id");
174
+
175
+                    b.HasIndex("RestaurantId");
176
+
177
+                    b.ToTable("MenuItems");
178
+                });
179
+
180
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.Restaurant", b =>
181
+                {
182
+                    b.Property<int>("Id")
183
+                        .ValueGeneratedOnAdd()
184
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
185
+
186
+                    b.Property<bool>("Chain");
187
+
188
+                    b.Property<DateTime>("Created");
189
+
190
+                    b.Property<decimal>("DeliveryFee");
191
+
192
+                    b.Property<decimal>("DeliveryRadius");
193
+
194
+                    b.Property<bool>("IsDeleted");
195
+
196
+                    b.Property<string>("Location");
197
+
198
+                    b.Property<string>("Logo");
199
+
200
+                    b.Property<string>("MethodsOfPayment");
201
+
202
+                    b.Property<DateTime>("Modified");
203
+
204
+                    b.Property<string>("ModifiedBy");
205
+
206
+                    b.Property<string>("Name");
207
+
208
+                    b.HasKey("Id");
209
+
210
+                    b.ToTable("Restaurants");
211
+                });
212
+
213
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
214
+                {
215
+                    b.Property<int>("Id")
216
+                        .ValueGeneratedOnAdd()
217
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
218
+
219
+                    b.Property<DateTime>("ClosingTime");
220
+
221
+                    b.Property<DateTime>("Created");
222
+
223
+                    b.Property<string>("Description");
224
+
225
+                    b.Property<bool>("IsDeleted");
226
+
227
+                    b.Property<DateTime>("Modified");
228
+
229
+                    b.Property<string>("ModifiedBy");
230
+
231
+                    b.Property<DateTime>("OpeningTime");
232
+
233
+                    b.Property<int>("RestaurantId");
234
+
235
+                    b.HasKey("Id");
236
+
237
+                    b.HasIndex("RestaurantId");
238
+
239
+                    b.ToTable("TradingHours");
240
+                });
241
+
118 242
             modelBuilder.Entity("ProRestaurant.Models.Accounts.DriverDetail", b =>
119 243
                 {
120 244
                     b.HasOne("ProRestaurant.Models.Accounts.User", "User")
@@ -130,6 +254,30 @@ namespace ProRestaurant.Migrations
130 254
                         .HasForeignKey("UserId")
131 255
                         .OnDelete(DeleteBehavior.Cascade);
132 256
                 });
257
+
258
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuCategory", b =>
259
+                {
260
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
261
+                        .WithMany()
262
+                        .HasForeignKey("RestaurantId")
263
+                        .OnDelete(DeleteBehavior.Cascade);
264
+                });
265
+
266
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.MenuItem", b =>
267
+                {
268
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
269
+                        .WithMany()
270
+                        .HasForeignKey("RestaurantId")
271
+                        .OnDelete(DeleteBehavior.Cascade);
272
+                });
273
+
274
+            modelBuilder.Entity("ProRestaurant.Models.Restaurants.TradingHours", b =>
275
+                {
276
+                    b.HasOne("ProRestaurant.Models.Restaurants.Restaurant", "Restaurant")
277
+                        .WithMany("TradingHours")
278
+                        .HasForeignKey("RestaurantId")
279
+                        .OnDelete(DeleteBehavior.Cascade);
280
+                });
133 281
 #pragma warning restore 612, 618
134 282
         }
135 283
     }

+ 22
- 0
ProRestaurant/Models/BaseObject.cs Zobrazit soubor

@@ -1,6 +1,8 @@
1 1
 using System;
2
+using System.Collections.Generic;
2 3
 using System.ComponentModel.DataAnnotations;
3 4
 using System.ComponentModel.DataAnnotations.Schema;
5
+using System.Reflection;
4 6
 
5 7
 namespace ProRestaurant.Models
6 8
 {
@@ -13,6 +15,7 @@ namespace ProRestaurant.Models
13 15
         public DateTime Created { get; set; } = DateTime.Now;
14 16
         public DateTime Modified { get; set; } = DateTime.Now;
15 17
         public string ModifiedBy { get; set; }
18
+        public bool IsDeleted { get; set; } = false;
16 19
         #endregion
17 20
 
18 21
         #region Methods
@@ -24,6 +27,25 @@ namespace ProRestaurant.Models
24 27
                 ModifiedBy = modifiedBy;
25 28
             }
26 29
         }
30
+
31
+        public object this[string propertyName]
32
+        {
33
+            get { return GetType().GetProperty(propertyName).GetValue(this, null); }
34
+            set { GetType().GetProperty(propertyName).SetValue(this, value, null); }
35
+        }
36
+
37
+        public string[] GetAllProperties()
38
+        {
39
+            if (this == null) return new string[] { };
40
+            Type t = GetType();
41
+            PropertyInfo[] props = t.GetProperties();
42
+            List<string> propNames = new List<string>();
43
+            foreach (PropertyInfo prp in props)
44
+            {
45
+                propNames.Add(prp.Name);
46
+            }
47
+            return propNames.ToArray();
48
+        }
27 49
         #endregion 
28 50
     }
29 51
 }

+ 13
- 0
ProRestaurant/Models/Restaurants/MenuCategory.cs Zobrazit soubor

@@ -0,0 +1,13 @@
1
+using System.ComponentModel.DataAnnotations.Schema;
2
+
3
+namespace ProRestaurant.Models.Restaurants
4
+{
5
+    public class MenuCategory : BaseObject
6
+    {
7
+        [ForeignKey("Restaurant")]
8
+        public int RestaurantId { get; set; }
9
+        public string Description { get; set; }
10
+
11
+        public virtual Restaurant Restaurant { get; set; }
12
+    }
13
+}

+ 11
- 15
ProRestaurant/Models/Restaurants/MenuItem.cs Zobrazit soubor

@@ -1,20 +1,16 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
1
+using System.ComponentModel.DataAnnotations.Schema;
5 2
 
6 3
 namespace ProRestaurant.Models.Restaurants
7 4
 {
8
-    //WIP
9
-    //public class MenuCategory : BaseObject
10
-    //{
11
-    //    public int RestaurantId { get; set; }
12
-    //    public string Description { get; set; }
13
-    //}
5
+    public class MenuItem : BaseObject
6
+    {
7
+        [ForeignKey("Restaurant")]
8
+        public int RestaurantId { get; set; }
9
+        public int CategoryId { get; set; }
10
+        public string Image { get; set; }
11
+        public string Description { get; set; }
12
+        public decimal Price { get; set; }
14 13
 
15
-    //public class MenuItem : BaseObject
16
-    //{
17
-    //    public int RestaurantId { get; set; }
18
-    //    public int CategoryId { get; set; }
19
-    //}
14
+        public virtual Restaurant Restaurant { get; set; }
15
+    }
20 16
 }

+ 7
- 7
ProRestaurant/Properties/launchSettings.json Zobrazit soubor

@@ -1,13 +1,13 @@
1
-{
2
-  "$schema": "http://json.schemastore.org/launchsettings.json",
1
+{
3 2
   "iisSettings": {
4
-    "windowsAuthentication": false, 
5
-    "anonymousAuthentication": true, 
3
+    "windowsAuthentication": false,
4
+    "anonymousAuthentication": true,
6 5
     "iisExpress": {
7 6
       "applicationUrl": "http://localhost:58847",
8
-      "sslPort": 44376
7
+      "sslPort": 0
9 8
     }
10 9
   },
10
+  "$schema": "http://json.schemastore.org/launchsettings.json",
11 11
   "profiles": {
12 12
     "IIS Express": {
13 13
       "commandName": "IISExpress",
@@ -21,10 +21,10 @@
21 21
       "commandName": "Project",
22 22
       "launchBrowser": true,
23 23
       "launchUrl": "api/values",
24
-      "applicationUrl": "https://localhost:5001;http://localhost:5000",
25 24
       "environmentVariables": {
26 25
         "ASPNETCORE_ENVIRONMENT": "Development"
27
-      }
26
+      },
27
+      "applicationUrl": "https://localhost:5001;http://localhost:5000"
28 28
     }
29 29
   }
30 30
 }

+ 3
- 1
ProRestaurant/Repository/Accounts/IUserRepository.cs Zobrazit soubor

@@ -1,4 +1,5 @@
1
-using ProRestaurant.Models.Accounts;
1
+using ProRestaurant.Containers;
2
+using ProRestaurant.Models.Accounts;
2 3
 using System;
3 4
 using System.Collections.Generic;
4 5
 using System.Linq;
@@ -14,5 +15,6 @@ namespace ProRestaurant.Repository.Accounts
14 15
         void Remove(User user);
15 16
         void Update(User user);
16 17
         void Save();
18
+        UserContainer Login(string UserName, string Password);
17 19
     }
18 20
 }

+ 49
- 2
ProRestaurant/Repository/Accounts/UserRepository.cs Zobrazit soubor

@@ -1,9 +1,14 @@
1 1
 using Microsoft.EntityFrameworkCore;
2
+using Microsoft.EntityFrameworkCore.Internal;
3
+using ProRestaurant.Classes;
4
+using ProRestaurant.Containers;
2 5
 using ProRestaurant.DBContexts;
3 6
 using ProRestaurant.Models.Accounts;
4 7
 using System;
5 8
 using System.Collections.Generic;
9
+using System.Diagnostics;
6 10
 using System.Linq;
11
+using System.Text.RegularExpressions;
7 12
 
8 13
 namespace ProRestaurant.Repository.Accounts
9 14
 {
@@ -18,7 +23,19 @@ namespace ProRestaurant.Repository.Accounts
18 23
 
19 24
         public User GetUser(Func<User, bool> where)
20 25
         {
21
-            return dBContext.Users.Where(where).FirstOrDefault();
26
+            var user = dBContext.Users.Where(where).FirstOrDefault();
27
+            if (user == null)
28
+            {
29
+                user = new User
30
+                {
31
+                    EmailAddress = "",
32
+                    Password = "",
33
+                    FirstName = "",
34
+                    Surname = "",
35
+                    Cellphone = ""
36
+                };
37
+            }
38
+            return user;
22 39
         }
23 40
 
24 41
         public IEnumerable<User> GetUsers()
@@ -27,11 +44,41 @@ namespace ProRestaurant.Repository.Accounts
27 44
         }
28 45
 
29 46
         public void Insert(User user)
30
-        {
47
+        {            
31 48
             dBContext.Add(user);
32 49
             Save();
33 50
         }
34 51
 
52
+        public UserContainer Login(string UserName, string Password)
53
+        {
54
+            UserContainer returnObject = new UserContainer();
55
+            User user;
56
+
57
+            string pattern = @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z";
58
+            if (Regex.IsMatch(UserName, pattern))
59
+                user = dBContext.Users.Where(u => u.EmailAddress == UserName).FirstOrDefault();
60
+            else
61
+                user = dBContext.Users.Where(u => u.Cellphone == UserName).FirstOrDefault();
62
+
63
+            if (user != null)
64
+            {
65
+                if (user.Password == Password)
66
+                {
67
+                    returnObject.user = user;
68
+                    returnObject.ResultString = "Access Granted";
69
+                }
70
+                else
71
+                    returnObject.ResultString = "Password incorrect";
72
+            }
73
+            else
74
+            {
75
+                returnObject.ResultString = "User not found";
76
+            }
77
+
78
+
79
+            return returnObject;
80
+        }
81
+
35 82
         public void Remove(User user)
36 83
         {
37 84
             dBContext.Users.Remove(user);

+ 7
- 0
ProRestaurant/Startup.cs Zobrazit soubor

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Builder;
6 6
 using Microsoft.AspNetCore.Hosting;
7 7
 using Microsoft.AspNetCore.HttpsPolicy;
8 8
 using Microsoft.AspNetCore.Mvc;
9
+using Microsoft.AspNetCore.Mvc.Cors.Internal;
9 10
 using Microsoft.EntityFrameworkCore;
10 11
 using Microsoft.Extensions.Configuration;
11 12
 using Microsoft.Extensions.DependencyInjection;
@@ -37,6 +38,12 @@ namespace ProRestaurant
37 38
             services.AddDbContext<DBContext>(o => o.UseSqlServer(Configuration.GetConnectionString("DefaultDatabase")));
38 39
 
39 40
             services.AddTransient<IUserRepository, UserRepository>();
41
+
42
+
43
+            services.Configure<MvcOptions>(options =>
44
+            {
45
+                options.Filters.Add(new CorsAuthorizationFilterFactory("MyPolicy"));
46
+            });
40 47
         }
41 48
         
42 49
         public void Configure(IApplicationBuilder app, IHostingEnvironment env)

binární
ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.dll Zobrazit soubor


binární
ProRestaurant/bin/Debug/netcoreapp2.2/ProRestaurant.pdb Zobrazit soubor


+ 7
- 7
ProRestaurant/bin/Debug/netcoreapp2.2/Properties/launchSettings.json Zobrazit soubor

@@ -1,13 +1,13 @@
1
-{
2
-  "$schema": "http://json.schemastore.org/launchsettings.json",
1
+{
3 2
   "iisSettings": {
4
-    "windowsAuthentication": false, 
5
-    "anonymousAuthentication": true, 
3
+    "windowsAuthentication": false,
4
+    "anonymousAuthentication": true,
6 5
     "iisExpress": {
7 6
       "applicationUrl": "http://localhost:58847",
8
-      "sslPort": 44376
7
+      "sslPort": 0
9 8
     }
10 9
   },
10
+  "$schema": "http://json.schemastore.org/launchsettings.json",
11 11
   "profiles": {
12 12
     "IIS Express": {
13 13
       "commandName": "IISExpress",
@@ -21,10 +21,10 @@
21 21
       "commandName": "Project",
22 22
       "launchBrowser": true,
23 23
       "launchUrl": "api/values",
24
-      "applicationUrl": "https://localhost:5001;http://localhost:5000",
25 24
       "environmentVariables": {
26 25
         "ASPNETCORE_ENVIRONMENT": "Development"
27
-      }
26
+      },
27
+      "applicationUrl": "https://localhost:5001;http://localhost:5000"
28 28
     }
29 29
   }
30 30
 }

binární
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.assets.cache Zobrazit soubor


+ 1
- 1
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csproj.CoreCompileInputs.cache Zobrazit soubor

@@ -1 +1 @@
1
-ae4ea08199583feb3ba95506c134065e2a0d2be7
1
+77194c0e6065fe8ba524baf1a69af7e606ad6513

+ 18
- 0
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csproj.FileListAbsolute.txt Zobrazit soubor

@@ -16,3 +16,21 @@ C:\Work\Development\ProRestaurant\ProResturantAPI\ProRestaurant\ProRestaurant\bi
16 16
 C:\Work\Development\ProRestaurant\ProResturantAPI\ProRestaurant\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.csproj.CoreCompileInputs.cache
17 17
 C:\Work\Development\ProRestaurant\ProResturantAPI\ProRestaurant\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.dll
18 18
 C:\Work\Development\ProRestaurant\ProResturantAPI\ProRestaurant\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.pdb
19
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\bin\Debug\netcoreapp2.2\appsettings.Development.json
20
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\bin\Debug\netcoreapp2.2\appsettings.json
21
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\bin\Debug\netcoreapp2.2\Properties\launchSettings.json
22
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\bin\Debug\netcoreapp2.2\ProRestaurant.deps.json
23
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\bin\Debug\netcoreapp2.2\ProRestaurant.runtimeconfig.json
24
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\bin\Debug\netcoreapp2.2\ProRestaurant.runtimeconfig.dev.json
25
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\bin\Debug\netcoreapp2.2\ProRestaurant.dll
26
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\bin\Debug\netcoreapp2.2\ProRestaurant.pdb
27
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.csprojAssemblyReference.cache
28
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.AssemblyInfoInputs.cache
29
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.AssemblyInfo.cs
30
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.csproj.CoreCompileInputs.cache
31
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.RazorAssemblyInfo.cache
32
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.RazorAssemblyInfo.cs
33
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.RazorTargetAssemblyInfo.cache
34
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.dll
35
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.pdb
36
+C:\Work\Development\ProRestaurant\RestaurantSite_API\ProRestaurant\obj\Debug\netcoreapp2.2\ProRestaurant.genruntimeconfig.cache

binární
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.csprojAssemblyReference.cache Zobrazit soubor


binární
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.dll Zobrazit soubor


binární
ProRestaurant/obj/Debug/netcoreapp2.2/ProRestaurant.pdb Zobrazit soubor


+ 5
- 5
ProRestaurant/obj/ProRestaurant.csproj.nuget.dgspec.json Zobrazit soubor

@@ -1,17 +1,17 @@
1 1
 {
2 2
   "format": 1,
3 3
   "restore": {
4
-    "C:\\Work\\Development\\ProRestaurant\\ProRestaurantAPI\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj": {}
4
+    "C:\\Work\\Development\\ProRestaurant\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj": {}
5 5
   },
6 6
   "projects": {
7
-    "C:\\Work\\Development\\ProRestaurant\\ProRestaurantAPI\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj": {
7
+    "C:\\Work\\Development\\ProRestaurant\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj": {
8 8
       "version": "1.0.0",
9 9
       "restore": {
10
-        "projectUniqueName": "C:\\Work\\Development\\ProRestaurant\\ProRestaurantAPI\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj",
10
+        "projectUniqueName": "C:\\Work\\Development\\ProRestaurant\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj",
11 11
         "projectName": "ProRestaurant",
12
-        "projectPath": "C:\\Work\\Development\\ProRestaurant\\ProRestaurantAPI\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj",
12
+        "projectPath": "C:\\Work\\Development\\ProRestaurant\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj",
13 13
         "packagesPath": "C:\\Users\\georg\\.nuget\\packages\\",
14
-        "outputPath": "C:\\Work\\Development\\ProRestaurant\\ProRestaurantAPI\\RestaurantSite_API\\ProRestaurant\\obj\\",
14
+        "outputPath": "C:\\Work\\Development\\ProRestaurant\\RestaurantSite_API\\ProRestaurant\\obj\\",
15 15
         "projectStyle": "PackageReference",
16 16
         "fallbackFolders": [
17 17
           "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"

+ 3
- 3
ProRestaurant/obj/project.assets.json Zobrazit soubor

@@ -12174,11 +12174,11 @@
12174 12174
   "project": {
12175 12175
     "version": "1.0.0",
12176 12176
     "restore": {
12177
-      "projectUniqueName": "C:\\Work\\Development\\ProRestaurant\\ProRestaurantAPI\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj",
12177
+      "projectUniqueName": "C:\\Work\\Development\\ProRestaurant\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj",
12178 12178
       "projectName": "ProRestaurant",
12179
-      "projectPath": "C:\\Work\\Development\\ProRestaurant\\ProRestaurantAPI\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj",
12179
+      "projectPath": "C:\\Work\\Development\\ProRestaurant\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj",
12180 12180
       "packagesPath": "C:\\Users\\georg\\.nuget\\packages\\",
12181
-      "outputPath": "C:\\Work\\Development\\ProRestaurant\\ProRestaurantAPI\\RestaurantSite_API\\ProRestaurant\\obj\\",
12181
+      "outputPath": "C:\\Work\\Development\\ProRestaurant\\RestaurantSite_API\\ProRestaurant\\obj\\",
12182 12182
       "projectStyle": "PackageReference",
12183 12183
       "fallbackFolders": [
12184 12184
         "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"

+ 2
- 2
ProRestaurant/obj/project.nuget.cache Zobrazit soubor

@@ -1,8 +1,8 @@
1 1
 {
2 2
   "version": 2,
3
-  "dgSpecHash": "iaSENNLeoDrP0E17PBbxDIM3wS4kUQ60CphPI10Ep+2nkLiZG8Lii8c7jAFLYYu8s/6Gs6+JxCLc0HOp9lkUTA==",
3
+  "dgSpecHash": "UKkCi2QfTZjSh7Mo0X5a3rAzjsBDnMmv390wbgjtgsJjh822kapoCSoPoj2ogBN40mGlTEqkNrv/q6FLyQUZhw==",
4 4
   "success": true,
5
-  "projectFilePath": "C:\\Work\\Development\\ProRestaurant\\ProRestaurantAPI\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj",
5
+  "projectFilePath": "C:\\Work\\Development\\ProRestaurant\\RestaurantSite_API\\ProRestaurant\\ProRestaurant.csproj",
6 6
   "expectedPackageFiles": [
7 7
     "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder\\microsoft.aspnet.webapi.client\\5.2.6\\microsoft.aspnet.webapi.client.5.2.6.nupkg.sha512",
8 8
     "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder\\microsoft.aspnetcore\\2.2.0\\microsoft.aspnetcore.2.2.0.nupkg.sha512",

Načítá se…
Zrušit
Uložit