You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
988 B
27 lines
988 B
using Dto;
|
|
using Entities;
|
|
using Shared;
|
|
using Shared.Mapper;
|
|
|
|
namespace API.Service;
|
|
|
|
public class UserDataServiceApi(IUserService<UserEntity> userService) : IUserService<UserDTO>
|
|
{
|
|
public IEnumerable<UserDTO> GetUsers(int page, int number)
|
|
{
|
|
var usersEntities = userService.GetUsers(page, number);
|
|
return usersEntities.Select(e => e.FromEntityToDTO()).ToList();
|
|
}
|
|
|
|
public UserDTO GetUserById(int id) => userService.GetUserById(id).FromEntityToDTO();
|
|
|
|
public UserDTO GetUserByUsername(string username) => userService.GetUserByUsername(username).FromEntityToDTO();
|
|
|
|
public bool DeleteUser(int id) => userService.DeleteUser(id);
|
|
|
|
public UserDTO UpdateUser(int id, UserDTO user) =>
|
|
userService.UpdateUser(id, user.FromDTOToEntity()).FromEntityToDTO();
|
|
|
|
public UserDTO CreateUser(string username, string password, string email, bool isAdmin) =>
|
|
userService.CreateUser(username, password, email, isAdmin).FromEntityToDTO();
|
|
} |