public TamagotchiController(ITamagotchiRepository repo) { if (repo == null) throw new ArgumentNullException(nameof(repo)); _repo = repo; }
public async Task <ActionResult> Index(int page = 0) { ITamagotchiRepository repo = GetRepo(); int per_page = await repo.TamagotchiPerPageAsync(); int all_count = await repo.TamagotchiCountAsync(); int page_num = (int)Math.Ceiling(all_count / (double)per_page); if (page > page_num) { page = page_num; } if (page < 0) { page = 0; } var tamagotchiContract = await repo.GetAllAsync(per_page *page); var param = new TamagotchiOverviewModel(tamagotchiContract, page, page_num); return(View(param)); }
public static void UnlinkRooms(List <Tamagotchi> _tamagotchis, ITamagotchiRepository _tamagotchiRepository) { foreach (var t in _tamagotchis) { t.CurrentRoom = null; _tamagotchiRepository.Update(t); } }
public TamagotchiController(ITamagotchiRepository repo) { if (repo == null) { throw new ArgumentNullException(nameof(repo)); } _repo = repo; }
private void GetContext(out ITamagotchiRepository repository, out Mock <DbSet <Tamagochi> > set, out Mock <TamagotchiEntities> context) { List <Tamagochi> data = new List <Tamagochi> { new Tamagochi() { Id = 1, Name = "Daano v Ethopie", Level = 0, Age = 0, Alive = 1, Currency = 100, Hapinness = 0, Health = 100 }, new Tamagochi() { Id = 2, Name = "Daan v Ethopie", Level = 0, Age = 0, Alive = 1, Currency = 100, Hapinness = 0, Health = 100 }, new Tamagochi() { Id = 3, Name = "Piet v Piet", Level = 0, Age = 0, Alive = 1, Currency = 100, Hapinness = 0, Health = 100 }, new Tamagochi() { Id = 4, Name = "Piethenjk v Ethopie", Level = 0, Age = 0, Alive = 1, Currency = 100, Hapinness = 0, Health = 100 }, new Tamagochi() { Id = 5, Name = "Henk v Ethopie", Level = 0, Age = 0, Alive = 1, Currency = 100, Hapinness = 0, Health = 100 }, new Tamagochi() { Id = 6, Name = "Piet v Ethopie", Level = 0, Age = 0, Alive = 1, Currency = 100, Hapinness = 0, Health = 100 } }; Mock <DbSet <Tamagochi> > mockSet = new Mock <DbSet <Tamagochi> >(); mockSet.As <IQueryable <Tamagochi> >().Setup(x => x.Provider).Returns(data.AsQueryable().Provider); mockSet.As <IQueryable <Tamagochi> >().Setup(x => x.Expression).Returns(data.AsQueryable().Expression); mockSet.As <IQueryable <Tamagochi> >().Setup(x => x.ElementType).Returns(data.AsQueryable().ElementType); mockSet.As <IQueryable <Tamagochi> >().Setup(x => x.GetEnumerator()).Returns(data.GetEnumerator()); mockSet.Setup(x => x.Add(It.IsAny <Tamagochi>())).Callback <Tamagochi>(x => data.Add(x)); mockSet.Setup(x => x.Remove(It.IsAny <Tamagochi>())).Callback <Tamagochi>(x => data.Remove(x)); Mock <TamagotchiEntities> contextMock = new Mock <TamagotchiEntities>(); contextMock.Setup(x => x.Tamagochis).Returns(mockSet.Object); repository = new TamagotchiDatabaseRepository(contextMock.Object); set = mockSet; context = contextMock; }
public HomeController(IHotelRoomRepository hotelRoomRepository, ITamagotchiRepository tamagotchiRepository) { _hotelRoomRepository = hotelRoomRepository; _tamagotchiRepository = tamagotchiRepository; }
public HomeController(IRoomRepository roomRepository, ITamagotchiRepository tamagotchiRepository) { _roomRepository = roomRepository; _tamagotchiRepository = tamagotchiRepository; }
public HomeController() { _roomRepository = new RoomRepository(new TamagotchiEntities()); _tamagotchiRepository = new TamagotchiRepository(new TamagotchiEntities()); }
public HomeController(ITamagotchiRepository tamagotchiRepository, IHotelkamerRepository hotelkamerRepository) { _tamagotchiRepository = tamagotchiRepository; _hotelkamerRepository = hotelkamerRepository; }
public TamagotchisController() { _tamagotchiRepository = new TamagotchiRepository(new TamagotchiEntities()); }
public TamagotchisController(ITamagotchiRepository tamagotchiRepository) { _tamagotchiRepository = tamagotchiRepository; }
public TamagotchiService(ITamagotchiRepository repo) { _repo = repo; }
public NightController(ITamagotchiRepository tamagotchiRepository, IHotelRoomRepository hotelRoomRepository) { _tamagotchiRepository = tamagotchiRepository; _hotelRoomRepository = hotelRoomRepository; }
public BookingController(IHotelRoomRepository hotelRoomRepository, ITamagotchiRepository tamagotchiRepository) { HotelRoomRepo = hotelRoomRepository; TamagotchiRepo = tamagotchiRepository; }
public static void ChangeProperties(ITamagotchiRepository tamagotchiRepository) { foreach (var t in tamagotchiRepository.GetAll()) { t.Level++; // Standaard mutaties if (t.Boredom >= 70) { t.Health -= 20; } if (t.Health <= 0) { t.Alive = false; } if (t.CurrentRoom != null) { // Kamer afhankelijke mutaties switch (t.CurrentRoom.Type) { case "Chillroom": t.Cents -= 10; t.Health += 20; t.Boredom += 10; break; case "Gameroom": t.Cents -= 10; t.Boredom = 0; break; case "Workroom": Random r = new Random(); int amountEarned = r.Next(10, 60); t.Cents += amountEarned; t.Boredom += 20; break; case "Fightroom": PickRandomWinner(tamagotchiRepository.GetAll()); break; case "DateRoom": t.Cents -= 10; t.Boredom -= 30; t.Health += 10; break; default: // Geen kamer t.Health -= 20; t.Boredom += 20; break; } } if (t.Health > 100) { t.Health = 100; } if (t.Boredom > 100) { t.Boredom = 100; } tamagotchiRepository.Update(t); } }
public TamagotchiService() { var kernel = new StandardKernel(new TamagotchiModule()); repo = kernel.Get <ITamagotchiRepository>(); }
//public ReservationController() //{ //} public ReservationController(IRoomRepository roomRepository, ITamagotchiRepository tamagotchiRepository, RoomViewModel detailsRoomVM) { this._roomRepository = roomRepository; this._tamagotchiRepository = tamagotchiRepository; this._detailsRoomVM = detailsRoomVM; }
public NachtController(IHotelkamerRepository hotelkamerRepository, IBoekingRepository boekingRepository, ITamagotchiRepository tamagotchiRepository) { _hotelkamerRepository = hotelkamerRepository; _boekingRepository = boekingRepository; _tamagotchiRepository = tamagotchiRepository; }
public NightController(ITamagotchiRepository tamagotchiRepository) { _tamagotchiRepository = tamagotchiRepository; _tamagotchis = _tamagotchiRepository.GetAll(); }
public TamagotchiService() { var kernel = new StandardKernel(new TamagotchiModule()); repo = kernel.Get<ITamagotchiRepository>(); }
public void TestInitialize() { _repo = new DummyTamagotchiRepository(); _service = new TamagotchiService(_repo); }