Esempio n. 1
0
        public async Task <bool> ResetAccountAsync(Account account)
        {
            if (int.TryParse(account.Id, out int accountId))
            {
                SqlAccount sqlAccount = await dbContext.SqlAccounts.FirstOrDefaultAsync(x => x.Id == accountId);

                sqlAccount.DeactivationDate = null;
                foreach (var assignement in sqlAccount.SqlAssignements)
                {
                    assignement.DeactivationDate = null;
                    await dbContext.SaveChangesAsync();
                }

                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        } // return the user passed on params

        public async Task <ICollection <User> > GetByEmailAsync(string email)
        {
            await Task.Delay(0);

            ObjectEmpty(email);
            SqlAccount sqlAccount = dbContext.SqlAccounts.Where(x => x.DeactivationDate == null).FirstOrDefault(x => x.Email == email);

            ObjectEmptyFromDb(sqlAccount);
            ICollection <SqlAssignement> sqlAssignements = dbContext.SqlAssignements.Where(x => x.SqlAccount == sqlAccount).Where(x => x.DeactivationDate == null).ToList();
            List <User> users = new List <User>();

            foreach (var user in sqlAssignements)
            {
                users.Add(mapper.Map <User>(user.SqlUser));
            }
            return(users);
        } // return a collection of user by email of account