Projekt

Obecné

Profil

« Předchozí | Další » 

Revize faa3619b

Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)

Added assigned documents count to GET /users

Zobrazit rozdíly:

Backend/Core/Services/UserService/UserServiceEF.cs
10 10
using BCrypt.Net;
11 11
using Models.Users;
12 12
using AutoMapper;
13
using Microsoft.EntityFrameworkCore;
13 14

  
14 15
namespace Core.Services
15 16
{
......
178 179
        }
179 180

  
180 181

  
181
        public UserList GetUsers() => new UserList()
182
        public UserList GetUsers()
182 183
        {
183
            Users = _databaseContext.Users.Select(u => _mapper.Map<UserInfo>(u)).ToList()
184
        };
184
            var userList = new UserList();
185
            var users = _databaseContext.Users.ToList();
186
            foreach (var user in users)
187
            {
188
                var userInfo = _mapper.Map<UserInfo>(user);
189
                userInfo.AssignedDocumentsCount = _databaseContext.Annotations.Include(a => a.User).Where(a => a.User == user).Count();
190
                userList.Users.Add(userInfo);
191
            }
192

  
193
            return userList;
194
        }
195

  
185 196

  
186 197
        public void DeleteUser(Guid userId)
187 198
        {

Také k dispozici: Unified diff