public TamagotchiController(ITamagotchiRepository repo)
        {
            if (repo == null)
                throw new ArgumentNullException(nameof(repo));

            _repo = repo;
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
 public static void UnlinkRooms(List <Tamagotchi> _tamagotchis, ITamagotchiRepository _tamagotchiRepository)
 {
     foreach (var t in _tamagotchis)
     {
         t.CurrentRoom = null;
         _tamagotchiRepository.Update(t);
     }
 }
Beispiel #4
0
        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;
 }
Beispiel #7
0
 public HomeController(IRoomRepository roomRepository, ITamagotchiRepository tamagotchiRepository)
 {
     _roomRepository       = roomRepository;
     _tamagotchiRepository = tamagotchiRepository;
 }
Beispiel #8
0
 public HomeController()
 {
     _roomRepository       = new RoomRepository(new TamagotchiEntities());
     _tamagotchiRepository = new TamagotchiRepository(new TamagotchiEntities());
 }
Beispiel #9
0
 public HomeController(ITamagotchiRepository tamagotchiRepository, IHotelkamerRepository hotelkamerRepository)
 {
     _tamagotchiRepository = tamagotchiRepository;
     _hotelkamerRepository = hotelkamerRepository;
 }
Beispiel #10
0
 public TamagotchisController()
 {
     _tamagotchiRepository = new TamagotchiRepository(new TamagotchiEntities());
 }
Beispiel #11
0
 public TamagotchisController(ITamagotchiRepository tamagotchiRepository)
 {
     _tamagotchiRepository = tamagotchiRepository;
 }
Beispiel #12
0
 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);
            }
        }
Beispiel #16
0
        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;
        }
Beispiel #18
0
 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>();
 }
Beispiel #21
0
 public void TestInitialize()
 {
     _repo    = new DummyTamagotchiRepository();
     _service = new TamagotchiService(_repo);
 }