static void Main() { try { var contextOptions = new DbContextOptionsBuilder <MonifierDbContext>() .UseSqlServer(ConnectionString) .Options; Console.WriteLine("Creating context..."); using (var context = new MonifierDbContext(contextOptions)) { using (var unitOfWork = new UnitOfWork(context)) { var authCommands = new AuthCommands(new EntityRepository(unitOfWork)); Console.WriteLine($"Creating user account for {Account.Name} (aka {Account.Login})..."); authCommands.CreateUser(Account.Name, Account.Login, Account.Password, Account.IsAdmin).Wait(); Console.WriteLine("Success"); } } } catch (Exception exc) { Console.WriteLine(exc.ToString()); } }
public User CreateUser(string name, string login, string password, bool isAdmin) { var authCommands = new AuthCommands(_repository); var userId = authCommands.CreateUser(name, login, password, isAdmin).Result; var userQueries = _unitOfWork.GetQueryRepository <User>(); return(userQueries.GetById(userId).Result); }