public MainWindow() { InitializeComponent(); _registrationViewModel = new RegistrationViewModel(); this.DataContext = _registrationViewModel; _dbContext = new FakeDB(); }
// dados persistentes, salvos em disco atraves das interações anteriores do usuário com o sistema public IBook[] GetReservations() { FakeDB faker = new FakeDB(); IBook[] books = faker.Load<Book[]>(); return books; }
public ViewResult Index(int?inCinemaFromYear, int?inCinemaFromMonth, int?inCinemaFromDay) { if (inCinemaFromYear == null) { inCinemaFromYear = 1800; } if (inCinemaFromMonth == null) { inCinemaFromMonth = 1; } if (inCinemaFromDay == null) { inCinemaFromDay = 1; } IEnumerable <Movie> movies = FakeDB.GetMovies() .Where(m => m.InCinemaFrom >= new DateTime((int)inCinemaFromYear, (int)inCinemaFromMonth, (int)inCinemaFromDay)); MoviesDataView mDV = new MoviesDataView() { Movies = movies }; return(View(mDV)); }
public async Task <Vehicle> GetAvailableVehicleAsync(int vehicleType) { Dictionary <int, Vehicle> dict = FakeDB.VehiclesTable(); var result = dict.Where(x => x.Value.CurrentlyRented == false && x.Value.VehicleTypeId == vehicleType).FirstOrDefault().Value; return(result); }
public async Task <IEnumerable <Rental> > ListAllAsync() { Dictionary <int, Rental> dict = FakeDB.RentalsTable(); List <Rental> result = dict.Values.OrderBy(x => x.Id).ToList(); return(result); }
public void Setup() { fakeDB = new FakeDB(); ClarityDB.Instance = fakeDB; ClarityDB.CurrentTenant = Presto.Persist <Tenant>(); service = new CategoryService(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { FakeDB.InitData(); services.AddScoped <IPetService, PetService>(); services.AddScoped <IPetRepository, PetRepository>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
public async Task <User> GetByName(string name) { Dictionary <int, User> dict = FakeDB.UsersTable(); User result = dict.Where(x => x.Value.Name == name).FirstOrDefault().Value; return(result); }
public ValuesController(ILogger <ValuesController> logger, FakeDB fakeDB, IServiceScopeFactory serviceScopeFactory, IBackGroundTaskQueue queue) { _logger = logger; _serviceScopeFactory = serviceScopeFactory; Queue = queue; _fakeSB = fakeDB; }
public Owner Create(Owner ownerToCreate) { List <Owner> updatedOwnersList = FakeDB.ReadOwnerData().ToList(); ownerToCreate.Id = FakeDB.GetNextOwnerId(); updatedOwnersList.Add(ownerToCreate); FakeDB.UpdateOwnerData(updatedOwnersList); return(ownerToCreate); }
public void InsertCustomer(Customer c) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } FakeDB.InsertCustomer(c); }
public ViewResult CustomerAdd() { CustomerDataView customerDV = new CustomerDataView() { Sexes = FakeDB.GetSelectListItemSex() }; return(View(customerDV)); }
public void CreateTest() { IAVISservice Test = new AVISservice(); Reservation newRes = Test.OpretReservation("Ford Focus", "Odense", DateTime.Today, DateTime.Today); FakeDB DB = new FakeDB(); DB.Insert(newRes); Assert.IsTrue(DB.DB.Contains(newRes)); }
public async Task <Rental> GetById(int id) { Dictionary <int, Rental> dict = FakeDB.RentalsTable(); if (!dict.ContainsKey(id)) { return(null); } return(dict[id]); }
public async Task <User> GetById(int id) { Dictionary <int, User> dict = FakeDB.UsersTable(); if (!dict.ContainsKey(id)) { return(null); } return(dict[id]); }
public MatchesModelViewFactory(RawFilterValues rawParameters) { db = new FakeDB(); MatchesFiltersValues filterValues = new MatchesFiltersValues(rawParameters); List <Match> matches = db.GetMatches(rawParameters).ToList <Match>(); matchesMV = new MatchesModelView(matches); matchesMV.GridFilters = getAllFilters(rawParameters); matchesMV.SetFilters(filterValues); }
public Pet Create(Pet petToCreate) { List <Pet> updatedPetsList = ReadAll().List.ToList(); petToCreate.Id = FakeDB.GetNextPetId(); petToCreate.Owner = FakeDB.ReadOwnerData().FirstOrDefault(o => o.Id == petToCreate.Owner.Id); updatedPetsList.Add(petToCreate); FakeDB.UpdatePetData(updatedPetsList); return(petToCreate); }
public void SetUp() { fakeDB = new FakeDB(); ClarityDB.Instance = fakeDB; Presto.Persist <User>(x => x.UserName = "******"); user = Presto.Persist <User>(x => x.UserName = "******"); fakeFormsAuthentication = new FakeFormsAuthentication(); service = new AuthenticationService(fakeFormsAuthentication, new FakePasswordHash(), null); }
public async Task <Vehicle> GetByIdAsync(int id) { Dictionary <int, Vehicle> dict = FakeDB.VehiclesTable(); if (!dict.ContainsKey(id)) { return(null); } return(dict[id]); }
public Customer GetCustomer(int id) { try { return(FakeDB.GetCustomer(id)); } catch { throw new HttpResponseException(HttpStatusCode.BadRequest); } }
public void DeleteCustomer(int id) { try { FakeDB.DeleteCustomer(id); } catch { throw new HttpResponseException(HttpStatusCode.BadRequest); } }
/// <summary> /// Creates the static data from the fake database(pet objects), /// calls the method for showing the primary menu, and another method for the selection of the primary menu /// </summary> public void StartUI() { Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Clear(); FakeDB.InitData(); var selection = ShowMenu(); HandleSelection(selection); }
public App() { InitializeComponent(); FakeDB.SeedData(); MainPage = new NavigationPage(new MainPage()) { BarBackgroundColor = Color.FromHex("#ffffff"), BarTextColor = Color.FromHex("#000000") }; }
public IActionResult RsvpForm(GuestResponse guestResponse) { if (ModelState.IsValid) { FakeDB.AddResponse(guestResponse); return(View("Thanks", guestResponse)); // Thanks.cshtml } else { return(View()); } }
public UnitOfWorkFakeDB() { _db = FakeDB.GetInstance(); _rollbackDb = new StaticDbRollback(_db); UserRepo = new UserRepository(_db); CourseRepo = new CourseRepository(_db); SectionRepo = new SectionRepository(_db); LessonRepo = new LessonRepository(_db); CategoryRepo = new CategoryRepository(_db); ApplicationRepo = new ApplicationRepository(_db); }
public ViewResult CustomerEdit(int customerId) { Customer customer = FakeDB.GetCustomers().First(c => c.Id == customerId); CustomerDataView customerDV = new CustomerDataView() { Sexes = FakeDB.GetSelectListItemSex(), Customer = customer, SexId = customer.Sex.Id }; return(View(customerDV)); }
public static void Main(string[] args) { FakeDB db = new FakeDB(); db.Add(new Person("Anton Timonin", 2700)); db.Add(new Person("Gergor Timonin", 0)); db.Add(new Company("RNA Bank", 17, 27000)); db.Add(new Person("Digo Eldigo", 800)); db.ShowFormateInfo(new ToJson()); db.ShowFormateInfo(new ToXml()); }
public async Task <RentalRepositoryResponse> UpdateRental(Rental rental) { Dictionary <int, Rental> dict = FakeDB.RentalsTable(); try { dict[rental.Id] = rental; } catch (Exception e) { return(new RentalRepositoryResponse(e.Message)); } return(new RentalRepositoryResponse(rental)); }
static void Main(string[] args) { FakeDB.InitData(); var serviceCollection = new ServiceCollection(); serviceCollection.AddScoped <IPetRepository, PetRepository>(); serviceCollection.AddScoped <IPetService, PetService>(); var serviceProvider = serviceCollection.BuildServiceProvider(); var petService = serviceProvider.GetRequiredService <IPetService>(); new Printer(petService); }
static void Main(string[] args) { FakeDB.initData(); ServiceCollection serCollect = new ServiceCollection(); serCollect.AddScoped <IPetRepository, PetRepository>(); serCollect.AddScoped <IPetService, PetService>(); serCollect.AddScoped <IPrinter, Printer>(); ServiceProvider service = serCollect.BuildServiceProvider(); IPrinter printer = service.GetRequiredService <IPrinter>(); printer.startUI(); }
public void CancelReservation(string bookReferenceNumber) { // removi as verificações de nulos, pois já são feitos em outra função; // idealmente não se deve fazer isso, mas para esse teste acredito que não será um problema FakeDB faker = new FakeDB(); // ajustado após a solução abaixo não funcionar List<IBook> booksToSave = GetReservations().Where(x => x.BookReference != bookReferenceNumber).ToList(); // estranhamente não funciona. deixei aqui a título de curiosidade //IBook book = FindReservation(bookReferenceNumber); //booksToSave.Remove(book); faker.Save(booksToSave); }
public FilteredList <Pet> ReadAll(Filter filter = null) { FilteredList <Pet> filteredList = new FilteredList <Pet>(); foreach (Pet p in FakeDB.ReadPetData()) { if (p.Owner == null) { continue; } p.Owner = FakeDB.ReadOwnerData().FirstOrDefault(o => o.Id == p.Owner.Id); filteredList.List.ToList().Add(p); } return(filteredList); }
public void Book(IBook rent) { // nosso amigo, o banco falso FakeDB faker = new FakeDB(); List<IBook> booksToSave; // adicionando a nova reserva. Se for a primeira cria do zero. IBook[] books = GetReservations(); if (books == null) booksToSave = new List<IBook>(); else booksToSave = books.ToList(); // impedindo duplicidade e escrevendo em disco if (!booksToSave.Any(x => x.BookReference == rent.BookReference)) { booksToSave.Add(rent); faker.Save(booksToSave); } }