public void ChangeTamagotchiStats() { // tamagotchis with NO booking var tamagotchis = _tamagotchiRepository.GetAllTamagotchisALiveAndNoHotelRoom(); this.HotelRoomBookingStayOverNight("No room", tamagotchis); foreach (var tamagotchi in tamagotchis) { _tamagotchiRepository.Edit(tamagotchi); } // tamagotchis with booking var hotelBookingsVM = _hotelBookingRepository.GetAll().Select(h => new HotelBookingVM(h)).ToList(); foreach (var hotelBookingVM in hotelBookingsVM) { this.HotelRoomBookingStayOverNight(hotelBookingVM.RoomType, hotelBookingVM.Tamagotchis); foreach (var tamagotchi in hotelBookingVM.Tamagotchis) { _tamagotchiRepository.Edit(tamagotchi); } _hotelBookingRepository.Delete(hotelBookingVM.ToModel()); } }
public ActionResult Edit(TamagotchiVM tamagotchiVM) { if (ModelState.IsValid) { _tamagotchiRepository.Edit(tamagotchiVM.ToModel()); return(RedirectToAction("Index")); } ViewBag.PlayerUserId = new SelectList(_playerUserRepository.GetAll(), "PlayerUserId", "PlayerUserName", tamagotchiVM.PlayerUserId); return(View(tamagotchiVM)); }
private void ChangeTamagotchiHotelRoom(HotelBookingVM hotelBookingVM) { if (hotelBookingVM.TamagotchisIds != null) { List <TamagotchiVM> tamagotchisVM = hotelBookingVM.TamagotchisIds.Select(ti => new TamagotchiVM(_tamagotchiRepository.GetWhereId(ti))).ToList(); foreach (var tamagotchiVM in tamagotchisVM) { tamagotchiVM.HotelBooking = null; tamagotchiVM.HotelRoomId = hotelBookingVM.HotelRoomId; _tamagotchiRepository.Edit(tamagotchiVM.ToModel()); } } }