P1_TrevorGraham/MvcStoreApplication/Repository/Repository.cs
/// <summary>
/// Attempts to add admin to db and returns whether or not it was successful
/// </summary>
/// <param name="admin"></param>
/// <returns></returns>
Attempts to add admin to db and returns whether or not it was successful
Attempts to add admin to db and returns whether or not it was successful
public bool AttemptAddAdministratorToDb(Administrator admin)
        {
            if (!AdministratorIsInDb(admin) && !UsernameAlreadyExists(admin.Username))
            {
                _dbContext.Administrators.Add(admin);
                _dbContext.SaveChanges();
                return AdministratorIsInDb(admin);
            }
            else
            {
            }
            return false;
        }
public bool AttemptAddAdministratorToDb ( Administrator admin ) { if ( ! AdministratorIsInDb ( admin ) && ! UsernameAlreadyExists ( admin . Username ) ) { _dbContext . Administrators . Add ( admin ) ; _dbContext . SaveChanges ( ) ; return AdministratorIsInDb ( admin ) ; } else { } return false ; }
Attempts to add admin to db and returns whether or not it was successful
Attempts to add admin to db and returns whether or not it was successful
//if there is not a product in the db with the same id or name //add it //TODO:check if admin was already in db and give some sort of warning
None
admin
Administrator
None