pcut_uwp/PCUT/PCUT.API/Managers/UserManager.cs

73 lines
1.6 KiB
C#
Raw Normal View History

2024-08-21 16:02:56 +00:00
using PCUT.Entities;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace PCUT.API.Managers
{
public class UserManager: ManagerBase<User>, IUserManager
{
string path = "users";
public async Task<User> CreateAsync(User entity)
{
try
{
return await ApiClient<User>.CreateAsync(path, entity);
}
catch {
return null;
}
}
public async Task<bool> DeleteAsync(int id)
{
try
{
return await ApiClient<User>.DeleteAsync(path, id);
}
catch
{
return false;
}
}
public async Task<List<User>> GetAllAsync()
{
try
{
return await ApiClient<User>.GetAllAsync(path);
}
catch
{
return null;
}
}
public async Task<User> GetByIdAsync(int id)
{
try
{
return await ApiClient<User>.GetByIdAsync(path, id);
}
catch
{
return null;
}
}
public async Task<User> UpdateAsync(int id, User entity)
{
try
{
return await ApiClient<User>.UpdateAsync(path, id, entity);
}
catch
{
return null;
}
}
}
}