static void Main(string[] args) { try { IRepository <int, Oferta> repoOffers = new OffersRepositoryMemory(new OfferValidator()); IRepository <int, User> repoUser = new UserFileRepository(new UserValidator(), "C:/Users/Geo/source/repos/AplicatieConsolaAgentieTursim/AplicatieConsolaAgentieTursim/Repository/User.txt"); Service.Service service = new Service.Service(repoOffers, repoUser); UI.Console console = new UI.Console(service); bool authenticated = console.Login(); if (authenticated) { console.RunMenu(); } else { Console.WriteLine("Login failed..."); } Console.ReadLine(); } catch (Exception ex) { Console.WriteLine("Unexpected exception " + ex.Message); Console.ReadKey(); } }
static void Main() { var path = Path.Combine(Directory.GetCurrentDirectory(), "users.txt"); IUserRepository userRepository = new UserFileRepository(path); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new InitialForm(userRepository)); }
protected CrudRepositoryTests <CNCLibContext, UserFileEntity, int, IUserFileRepository> CreateTestContext() { return(new CrudRepositoryTests <CNCLibContext, UserFileEntity, int, IUserFileRepository>() { CreateTestDbContext = () => { var context = TestFixture.CreateDbContext(); var uow = new UnitOfWork <CNCLibContext>(context); var rep = new UserFileRepository(context); return new CrudTestDbContext <CNCLibContext, UserFileEntity, int, IUserFileRepository>(context, uow, rep); }, GetEntityKey = (entity) => entity.UserFileId, SetEntityKey = (entity, id) => entity.UserFileId = id, CompareEntity = (entity1, entity2) => entity1.ArePropertiesEqual(entity2, new[] { @"UserFileId" }) }); }
public UnitOfWork(RepositoryPatternDbContext context) { _context = context; UserFileRepository = new UserFileRepository(context); FileRepository = new FileRepository(context); }
public UnitOfWork(string connection, IContextService instance) { _logger = LoggerFactory.Create(opt => { opt.AddFilter("Microsoft", LogLevel.Warning) .AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Information) .AddFilter("System", LogLevel.Warning) .AddConsole(); }); switch (instance.InstanceType) { case InstanceContext.DeployedOrLocal: { #if !RELEASE var builder = new DbContextOptionsBuilder <AuroraEntities>() .UseSqlServer(connection); //.UseLoggerFactory(_logger) //.EnableSensitiveDataLogging(); #elif RELEASE var builder = new DbContextOptionsBuilder <AuroraEntities>() .UseSqlServer(connection); #endif _context = new AuroraEntities(builder.Options); } break; case InstanceContext.End2EndTest: case InstanceContext.IntegrationTest: case InstanceContext.UnitTest: { #if !RELEASE var builder = new DbContextOptionsBuilder <AuroraEntities>() .UseInMemoryDatabase(":InMemory:") .UseLoggerFactory(_logger) .EnableSensitiveDataLogging(); #elif RELEASE var builder = new DbContextOptionsBuilder <AuroraEntities>() .UseInMemoryDatabase(":InMemory:"); #endif _context = new AuroraEntities(builder.Options); } break; default: throw new NotImplementedException(); } _context.ChangeTracker.LazyLoadingEnabled = false; _context.ChangeTracker.CascadeDeleteTiming = CascadeTiming.Immediate; InstanceType = instance.InstanceType; Credentials = new CredentialRepository(_context); Networks = new NetworkRepository(_context); PrivateKeys = new PrivateKeyRepository(_context); PublicKeys = new PublicKeyRepository(_context); Settings = new SettingRepository(_context); UserFiles = new UserFileRepository(_context); UserFolders = new UserFolderRepository(_context); UserMounts = new UserMountRepository(_context); Users = new UserRepository(_context); }