// GET: Tamagotchis/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TamagotchiModel tamagotchi = _tamagotchiRepository.Get(id.Value); if (tamagotchi == null) { return(HttpNotFound()); } return(View(tamagotchi)); }
public ActionResult Book([Bind(Include = "Room,Tamagotchis")] BookingViewModel viewModel) { if (ModelState.IsValid && viewModel.Tamagotchis.Count() <= viewModel.Room.Size) { foreach (string i in viewModel.Tamagotchis) { viewModel.Room.Tamagotchi.Add(_tamagotchiRepository.Get(int.Parse(i))); _tamagotchiRepository.Get(int.Parse(i)).Room = viewModel.Room.Id; _tamagotchiRepository.Get(int.Parse(i)).Room1 = viewModel.Room; _tamagotchiRepository.Update(_tamagotchiRepository.Get(int.Parse(i))); } _roomRepository.Update(viewModel.Room); return(RedirectToAction("Index")); } IEnumerable <SelectListItem> basetypes = _tamagotchiRepository.GetAll().Where(e => e.Alive && e.Room == null && e.Money >= _roomRepository.Get(viewModel.Room.Id).Cost).Select( b => new SelectListItem { Value = b.Id.ToString(), Text = b.Name }); ViewData["tamagotchis"] = basetypes; return(View(viewModel)); }
string StartDetailView(TamagotchiContract tama) { if (tama == null) { return(""); } while (true) { System.Console.Clear(); WriteHeader(); WriteTamagotchiStatus(tama); if (tama.IsInCoolDown) { WriteLine(); WriteLine($"Cooldown in effect until {tama.CoolDownUntilUtc.ToLocalTime()}."); if (tama.CoolDownLeft.Hours > 0) { WriteLine($" Cooldown will take another {tama.CoolDownLeft.Hours} hours {tama.CoolDownLeft.Minutes} minutes and {tama.CoolDownLeft.Seconds} seconds."); } else if (tama.CoolDownLeft.Hours == 0 && tama.CoolDownLeft.Minutes > 0) { WriteLine($" Cooldown will take another {tama.CoolDownLeft.Minutes} minutes and {tama.CoolDownLeft.Seconds} seconds."); } else if (tama.CoolDownLeft.Hours == 0 && tama.CoolDownLeft.Minutes == 0) { WriteLine($" Cooldown will take another {tama.CoolDownLeft.Seconds} seconds."); } } WriteLine(); WriteLine("Type [quit] to close the application." + NewLine + "Type [back] to go back to the Tamgotchi overview." + NewLine + "Type [rules] to view the rules for this Tamagotchi." + NewLine + "Type [refresh]/[r] to update this page."); if (tama.HasDied) { WriteLine("Type [delete] to delete this Tamagotchi."); } if (!tama.IsInCoolDown && !tama.HasDied) { WriteLine("Available actions:" + NewLine + " [eat] [sleep] [play] [workout] [hug]"); } WriteLine(); try { _repo.HasData(); } catch (Exception) { ShowConnectionError(); } string input = AskForInput(); if (input == "quit" || input == "back") { return(input); } switch (input) { case "quit": case "back": return(input); case "refresh": case "r": try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "eat": if (!_repo.Eat(tama.Name)) { AskForInput("Action not available, press any button to continue"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "sleep": if (!_repo.Sleep(tama.Name)) { AskForInput("Action not available, press any button to continue"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "play": if (!_repo.Play(tama.Name)) { AskForInput("Action not available, press any button to continue"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "workout": if (!_repo.Workout(tama.Name)) { AskForInput("Action not available, press any button to continue"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "hug": if (!_repo.Hug(tama.Name)) { AskForInput("Action not available, press any button to continue"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "rule": case "rules": var output = StartRulesView(tama); if (output == "quit") { return("quit"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "delete": case "remove": case "d": if (!tama.HasDied) { WriteLine("Alive Tamagotchis cannot be deleted.", ConsoleColor.Red); AskForInput("Press any button to continue"); break; } try { _repo.Remove(tama.Name); } catch (Exception) { ShowConnectionError(); } return("back"); case "delete -g": case "remove -g": case "d -g": try { _repo.Remove(tama.Name); } catch (Exception) { ShowConnectionError(); } return("back"); default: WriteLine("Command not recognized.", ConsoleColor.Red); AskForInput("Press any button to continue"); break; } } }
public bool ActivateRuleForTamagotchiByName(string tamagotchiName, string ruleName) { return(SetIsActiveForRule(repo.Get(tamagotchiName), ruleName, true)); }
public RoomViewModel ProcessReservation(RoomViewModel roomVM) { _detailsRoomVM.AmountOfTamagotchis = roomVM.AmountOfTamagotchis; _detailsRoomVM.Room = roomVM.Room; _detailsRoomVM.SelectedTamagotchisIDList = roomVM.SelectedTamagotchisIDList; _detailsRoomVM.Tamagotichis = roomVM.SelectedTamagotchisIDList.Select(ti => _tamagotchiRepository.Get(ti)).ToList(); return(roomVM); }