public static async Task <ApplicationUser> Update_User_Profile(ApplicationDbContext context, ApplicationUser entity, bool isAdmin = true) { ApplicationUser user; if (entity.Id != null && entity.Id != "") { user = await context.AspNetusers .Where(p => p.Id == entity.Id) .FirstOrDefaultAsync(); } else { user = await context.AspNetusers .Where(p => p.UserName == entity.UserName) .FirstOrDefaultAsync(); } if (user != null) { user.firstname = UtilityBLL.processNull(entity.firstname, 0); user.lastname = UtilityBLL.processNull(entity.lastname, 0); context.Entry(user).State = EntityState.Modified; context.SaveChanges(); if (isAdmin) { // update settings entity.settings.userid = entity.Id; await UserSettingsBLL.Update(context, entity.settings); } } return(entity); }
public static async Task DropUserProfile(ApplicationDbContext context, ApplicationUser entity) { // Delete User Stats await UserStatsBLL.Delete(context, entity.Id); // Delete User Settings await UserSettingsBLL.Delete(context, entity.Id); }
public static async Task InitializeUserProfile(ApplicationDbContext context, ApplicationUser entity) { // Initialize User Settings await UserSettingsBLL.Add(context, new JGN_User_Settings() { userid = entity.Id, isemail = 1, issendmessages = 1 }); // activate both isemail / issendmessages enabled until having custom requirements. }