Exemplo n.º 1
0
 public GenericActionResult <UserCreditResponseModel> GetUserCreditById(int id)
 {
     try
     {
         return(GenericActionResult <UserCreditResponseModel> .FromObject(context.UserCredits.Where(a => a.Id == id && !a.IsDeleted).Select(a => new ObjectConverterManager(context, userManager).ToUserCreditResponseModel(a)).FirstOrDefault()));
     }
     catch (Exception) { return(new GenericActionResult <UserCreditResponseModel>("Failed to get credit, please try again or contact the administrator.")); }
 }
Exemplo n.º 2
0
 public GenericActionResult <List <UserCreditResponseModel> > GetUserCreditByUserId(string userId)
 {
     try
     {
         var credits = context.UserCredits.Where(a => a.UserId.Equals(userId) && !a.IsDeleted).ToList();
         return(GenericActionResult <List <UserCreditResponseModel> > .FromObject(credits.Select(a => new ObjectConverterManager(context, userManager).ToUserCreditResponseModel(a)).ToList()));
     }
     catch (Exception) { return(new GenericActionResult <List <UserCreditResponseModel> >("Failed to get credits, please try again or contact the administrator.")); }
 }
Exemplo n.º 3
0
 public GenericActionResult <List <UserCreditResponseModel> > GetAllUserCredits(int skip, int take)
 {
     try
     {
         var credits = context.UserCredits.Where(a => !a.IsDeleted).Skip(skip).Take(take).ToList();
         return(GenericActionResult <List <UserCreditResponseModel> > .FromObject(credits.Select(
                                                                                      a => new ObjectConverterManager(context, userManager).ToUserCreditResponseModel(a)).ToList()));
     }
     catch (Exception) { return(new GenericActionResult <List <UserCreditResponseModel> >("Failed to get credits, please try again or contact the administrator.")); }
 }
Exemplo n.º 4
0
 public GenericActionResult <List <UserModel> > GetAllUser()
 {
     try
     {
         var users = userManager.Users.ToListAsync().Result;
         return(GenericActionResult <List <UserModel> > .FromObject(users.Select(a => new UserModel
         {
             UserId = a.Id,
             DateCreated = a.DateCreated,
             Email = a.Email,
             UserName = a.UserName,
             PhoneNumber = a.PhoneNumber,
             IsConfirmed = a.EmailConfirmed,
             Roles = userManager.GetRolesAsync(a).Result
         }).ToList()));
     }
     catch (Exception exception)
     {
         return(new GenericActionResult <List <UserModel> >(exception.Message));
     }
 }