public async Task <bool> DeleteAspNetUserAsync(int id) { try { using (var db = new FutsalEntities()) { var aspNetUser = await db.AspNetUsers.FindAsync(id); if (aspNetUser != null) { aspNetUser.IsDeleted = true; aspNetUser.LastUpdatedByUser = 1; aspNetUser.LastUpdatedDate = DateTime.Now; db.Entry(aspNetUser).State = EntityState.Modified; await db.SaveChangesAsync(); return(true); } return(false); } } catch (Exception ex) { throw ex; } }
public void PostApplicationLogAsync(ApplicationLog applicationLog) { using (var dbContext = new FutsalEntities()) { dbContext.ApplicationLogs.Add(applicationLog); dbContext.SaveChanges(); } }
public async Task <int> GetAspNetUserByIdAsync(string loggedInUser) { using (var db = new FutsalEntities()) { var users = await db.AspNetUsers.Where(p => p.UserName == loggedInUser).SingleAsync(); return(users == null ? 0 : users.Id); } }
public async Task <IEnumerable <UserRoles_Search_Result> > GetActiveUserRoles() { try { using (var db = new FutsalEntities()) { return(db.UserRoles_Search(null, null, null, null, 0, 25, null).ToList()); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Gets the ASP net user by email address asynchronous. /// </summary> /// <param name="email">The email.</param> /// <returns>AspNetUser</returns> public async Task <AspNetUser> GetAspNetUserAsync(string email) { try { using (var db = new FutsalEntities()) { return(await db.AspNetUsers.Where(p => p.Email == email).SingleOrDefaultAsync()); } } catch (System.Exception ex) { throw ex; } }
public async Task <AspNetRole> FindRolesAsync(int roleId) { try { using (var db = new FutsalEntities()) { return(await db.AspNetRoles.FindAsync(roleId)); } } catch (Exception ex) { throw ex; } }
public async Task <IEnumerable <AspNetRole> > GetAllRolesAsync() { try { using (var db = new FutsalEntities()) { return(await db.AspNetRoles.ToListAsync()); } } catch (System.Exception ex) { throw ex; } }
public IEnumerable <AspNetUser> GetActiveAspNetUsers() { try { using (var db = new FutsalEntities()) { return(db.AspNetUsers.Where(p => p.IsUserActive == true && p.IsDeleted == false).ToList()); } } catch (System.Exception ex) { throw ex; } }
public Task <AspNetUserRole> GetAspNetUserRolebyIdAsync(int userRoleId) { try { using (var db = new FutsalEntities()) { return(db.AspNetUserRoles.Where(p => p.Id == userRoleId && p.IsDeleted == false).SingleAsync()); } } catch (System.Exception ex) { throw ex; } }
/// <summary> /// Gets the application name asynchronous. /// </summary> /// <returns></returns> public async Task <string> GetApplicationNameAsync() { try { using (var dbContext = new FutsalEntities()) { return((await dbContext.Applications.Where(x => x.Name == Constants.ApplicationName).SingleAsync()).Name); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Gets the ASP net user by user id address asynchronous. /// </summary> /// <param name="id">The user id.</param> /// <returns> AspNetUser</returns> public async Task <AspNetUser> GetAspNetUserByIdAsync(int id) { try { using (var db = new FutsalEntities()) { return(await db.AspNetUsers.Where(p => p.Id == id).SingleOrDefaultAsync()); } } catch (System.Exception ex) { throw ex; } }
/// <summary> /// Finds the ASP net user asynchronously by aspnet user id. /// </summary> /// <param name="id">The Aspnet user ID.</param> /// <returns>aspnet user </returns> public async Task <AspNetUser> FindAspNetUserAsync(int id) { try { using (var db = new FutsalEntities()) { return(await db.AspNetUsers.FindAsync(id)); } } catch (Exception ex) { throw ex; } }
public async Task PostUserHistoryAsync(UserHistory userHistory) { try { using (var db = new FutsalEntities()) { db.UserHistories.Add(userHistory); await db.SaveChangesAsync(); } } catch (System.Exception ex) { throw ex; } }
public async Task InsertIntoUserLoginAttemptsAsync(UserLoginAttempt userLoginAttempt) { try { using (var db = new FutsalEntities()) { db.UserLoginAttempts.Add(userLoginAttempt); await db.SaveChangesAsync(); } } catch (Exception ex) { throw ex; } }
public bool AssignRoleToUser(int userId, string role, int loggedInUserId) { try { var result = new ObjectParameter("Result", typeof(bool)); using (var db = new FutsalEntities()) { int response = db.UserRole_Assign(userId, role, loggedInUserId, result); return(!string.IsNullOrEmpty(result.Value.ToString()) ? true : false); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Updates the editted Aspnet user. /// </summary> /// <param name="aspNetUser">The ASP net user.</param> /// <returns>updated aspnet user</returns> public async Task <AspNetUser> UpdateAspNetUserAsync(AspNetUser aspNetUser) { try { using (var db = new FutsalEntities()) { db.Entry(aspNetUser).State = EntityState.Modified; await db.SaveChangesAsync(); } } catch (Exception ex) { var sth = ex;//log error here } return(aspNetUser); }
public async Task <bool> UpdateRoleAsync(AspNetRole aspnetrole) { try { using (var db = new FutsalEntities()) { db.Entry(aspnetrole).State = EntityState.Modified; await db.SaveChangesAsync(); return(true); } } catch (Exception ex) { return(false); } }
public async Task <bool> PostAspNetUserAsync(AspNetUser aspnetuser) { try { using (var db = new FutsalEntities()) { db.AspNetUsers.Add(aspnetuser); await db.SaveChangesAsync(); return(true); } } catch (System.Exception ex) { throw ex; } }
/// <summary> /// Validate the username and email association /// Does the username with the email addres exist? /// </summary> /// <param name="username"></param> /// <param name="email"></param> /// <returns>true if the username email association is found. False , if not found</returns> public async Task <bool> GetAspNetUserAsync(string username, string email) { try { using (var db = new FutsalEntities()) { var user = await db.AspNetUsers.Where(p => p.UserName == username && p.Email == email).SingleOrDefaultAsync(); return(user == null ? false : true); } } catch (Exception ex) { var sth = ex; // throw ex; //log error here return(false); } }
public async Task <bool> CreateRoleAsync(string roleName, int createdByUser) { try { using (var db = new FutsalEntities()) { var aspnetrole = new AspNetRole() { Name = roleName, CreatedByUser = createdByUser, LastUpdatedByUser = createdByUser, CreatedDate = DateTime.Now, LastUpdatedDate = DateTime.Now }; db.AspNetRoles.Add(aspnetrole); await db.SaveChangesAsync(); return(true); } } catch (Exception ex) { return(false); } }