Ejemplo n.º 1
0
        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);

            // Delete User Account
            await UserAccountBLL.Delete(context, entity.Id);
        }
Ejemplo n.º 2
0
        public static async Task InitializeUserProfile(ApplicationDbContext context, ApplicationUser entity)
        {
            // Initialize User Stats
            await UserStatsBLL.Add(context, new JGN_User_Stats()
            {
                userid = entity.Id
            });

            // 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.

            // Initialize User Account
            await UserAccountBLL.Add(context, new JGN_User_Account()
            {
                userid = entity.Id
            });
        }
Ejemplo n.º 3
0
        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);

                    // update account
                    entity.account.userid = entity.Id;
                    await UserAccountBLL.Update(context, entity.account);
                }
            }

            return(entity);
        }