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

73 lines
1.6 KiB
C#

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;
}
}
}
}