//GET: Boss/Details public ActionResult Details(int id) { var service = new BossService(); var model = service.GetBossByID(id); return(View(model)); }
public TwitchBot(string _channelName) { //Init Client twitchClient = new TwitchClient(); twitchPubSub = new TwitchPubSub(); //Init Database this.db = new AppDbContextFactory().Create(); //Init access accessService = new AccessService(); //Init Twitch API api = new TwitchAPI(); api.Settings.ClientId = accessService.GetTwitchClientID(); api.Settings.AccessToken = accessService.GetTwitchAccessToken(); //Init services this.achievementService = new AchievementService(db); this.settingsService = new SettingsService(db); this.pokemonService = new PokemonService(db); userService = new UserService(db, api); chatOutputService = new ChatOutputService(twitchClient, _channelName); bossService = new BossService(userService, pokemonService, chatOutputService, settingsService); userfightService = new UserfightService(userService, chatOutputService); chatService = new ChatInputService(userService, chatOutputService, bossService, userfightService, achievementService); destinationChannelName = _channelName; Connect(); }
public ActionResult DeleteBoss(int id) { var service = new BossService(); service.DeleteBoss(id); TempData["SaveResult"] = "Boss deleted"; return(RedirectToAction("Index")); }
public ActionResult Create(BossCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = new BossService(); if (service.CreateBoss(model)) { TempData["SaveResult"] = "Boss created"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Boss could not be created"); return(View(model)); }
// GET: Boss //public ActionResult Index() //{ // var service = new BossService(); // var model = service.GetBosses(); // return View(model); //} public ActionResult Index(string sortOrder) { ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; var service = new BossService(); var bosses = from boss in service.GetBosses() select boss; switch (sortOrder) { case "name_desc": bosses = bosses.OrderBy(boss => boss.Name); break; default: bosses.OrderBy(b => b.ID); break; } return(View(bosses.ToList())); }
//GET: Boss/Edit public ActionResult Edit(int id) { var service = new BossService(); var detail = service.GetBossByID(id); var locationService = new LocationService(); ViewBag.LocationID = new SelectList(ctx.Locations.ToList(), "ID", "Name"); var model = new BossEdit { Name = detail.Name, Description = detail.Description, Health = detail.Health, Weakness = detail.Weakness, Location = detail.Location, LocationID = detail.LocationID, Tips = detail.Tips }; return(View(model)); }
public ActionResult Edit(int id, BossEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ID != id) { ModelState.AddModelError("", "Wrong ID"); return(View(model)); } var service = new BossService(); if (service.UpdateBoss(model)) { TempData["SaveResult"] = "Boss updated"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Error"); return(View(model)); }