Explorar el Código

Agents added on a agency

master
LeneS hace 5 años
padre
commit
b97515ba07

+ 1
- 0
UnivateProperties_API/Controllers/Users/AgentController.cs Ver fichero

@@ -34,6 +34,7 @@ namespace User_API.Controllers
34 34
         {
35 35
             using (var scope = new TransactionScope())
36 36
             {
37
+                
37 38
                 _Repo.Insert(agent);
38 39
                 scope.Complete();
39 40
                 return CreatedAtAction(nameof(Get), new { id = agent.Id }, agent);

+ 2
- 4
UnivateProperties_API/Controllers/Users/RegisterController.cs Ver fichero

@@ -50,21 +50,19 @@ namespace UnivateProperties_API.Controllers.Users
50 50
                 Subject = new ClaimsIdentity(new Claim[]
51 51
                 {
52 52
                     new Claim(ClaimTypes.Name, user.Id.ToString()),
53
-                    new Claim(ClaimTypes.Role, user.Role)
53
+                    //new Claim(ClaimTypes.Role, user.Role)
54 54
                 }),
55 55
                 Expires = DateTime.UtcNow.AddMinutes(15),
56 56
                 SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
57 57
             };
58 58
             var token = tokenHandler.CreateToken(tokenDescriptor);
59
-            var tokenString = tokenHandler.WriteToken(token);
59
+            var tokenString = tokenHandler.WriteToken(token); 
60 60
 
61 61
             // return basic user info (without password) and token to store client side
62 62
             return Ok(new
63 63
             {
64 64
                 user.Id,
65 65
                 user.Username,
66
-                user.Name,
67
-                user.Surname,
68 66
                 Token = tokenString
69 67
             });
70 68
         }

+ 1
- 0
UnivateProperties_API/Controllers/Users/UserController.cs Ver fichero

@@ -7,6 +7,7 @@ using UnivateProperties_API.Repository.Users;
7 7
 
8 8
 namespace User_API.Controllers
9 9
 {
10
+    //[Authorize]
10 11
     [Route("api/[controller]")]
11 12
     [ApiController]
12 13
     public class UserController : ControllerBase

+ 0
- 2
UnivateProperties_API/Model/Users/User.cs Ver fichero

@@ -10,8 +10,6 @@
10 10
         #endregion Constructor
11 11
 
12 12
         #region Properties
13
-        public string Name { get; set; }
14
-        public string Surname { get; set; }
15 13
         public string Username { get; set; }
16 14
         public string Role { get; set; }
17 15
         public byte[] PasswordHash { get; set; }

+ 9
- 1
UnivateProperties_API/Repository/Users/AgentRepository.cs Ver fichero

@@ -42,13 +42,21 @@ namespace UnivateProperties_API.Repository.Users
42 42
 
43 43
         public void Insert(Agent item)
44 44
         {
45
+            if (item.AgencyId != 0 && item.Agency == null)
46
+            {
47
+                AgencyRepository arepo = new AgencyRepository(_dbContext);
48
+                item.Agency = arepo.Get(a => a.Id == item.AgencyId).FirstOrDefault();
49
+            }
45 50
             _dbContext.Add(item);
46 51
             Save();
47 52
         }
48 53
 
49 54
         public void Insert(IEnumerable<Agent> item)
50 55
         {
51
-            _dbContext.Add(item);
56
+            foreach (var i in item)
57
+            {
58
+                _dbContext.Add(item);
59
+            }
52 60
             Save();
53 61
         }
54 62
 

+ 0
- 2
UnivateProperties_API/Repository/Users/RegisterRepository.cs Ver fichero

@@ -165,8 +165,6 @@ namespace UnivateProperties_API.Repository.Users
165 165
             }
166 166
 
167 167
             // update user properties
168
-            user.Name = userParam.Name;
169
-            user.Surname = userParam.Surname;
170 168
             user.Username = userParam.Username;
171 169
 
172 170
             // update password if it was entered

+ 0
- 2
UnivateProperties_API/Repository/Users/UserRepository.cs Ver fichero

@@ -103,8 +103,6 @@ namespace UnivateProperties_API.Repository.Users
103 103
             }
104 104
 
105 105
             // update user properties
106
-            user.Name = userParam.Name;
107
-            user.Surname = userParam.Surname;
108 106
             user.Username = userParam.Username;
109 107
 
110 108
             // update password if it was entered

+ 7
- 4
UnivateProperties_API/UnivateProperties_API.csproj Ver fichero

@@ -5,6 +5,13 @@
5 5
     <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
6 6
   </PropertyGroup>
7 7
 
8
+  <ItemGroup>
9
+    <Compile Remove="Migrations\**" />
10
+    <Content Remove="Migrations\**" />
11
+    <EmbeddedResource Remove="Migrations\**" />
12
+    <None Remove="Migrations\**" />
13
+  </ItemGroup>
14
+
8 15
   <ItemGroup>
9 16
     <Compile Remove="Model\Users\AgencyAgent.cs" />
10 17
   </ItemGroup>
@@ -20,8 +27,4 @@
20 27
     <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.4" />
21 28
   </ItemGroup>
22 29
 
23
-  <ItemGroup>
24
-    <Folder Include="Migrations\" />
25
-  </ItemGroup>
26
-
27 30
 </Project>

Loading…
Cancelar
Guardar