private async Task <DojoStatistics> GenerateDojoStatisticsAsync(Dojo dojo) { var mostFrequent = await GetMostFrequentSolutionLanguageByDojoIdAsync(dojo.Id); var leastFrequent = await GetLeastFrequentSolutionLanguageByDojoIdAsync(dojo.Id); var solvedUserIds = (await ListUserIdsByDojoIdAsync(dojo.Id)).ToList(); return(new DojoStatistics { Id = dojo.Id, Difficulty = dojo.Difficulty, Name = dojo.Title, SolvedUserIds = solvedUserIds, NumOfUsersSolved = solvedUserIds.Count, MostFrequentlySolvedInLanguage = new Dictionary <string, double> { { mostFrequent, await GetSolutionRatioForDojoByLanguageAsync(dojo.Id, mostFrequent) } }, LeastFrequentlySolvedInLanguage = new Dictionary <string, double> { { leastFrequent, await GetSolutionRatioForDojoByLanguageAsync(dojo.Id, leastFrequent) } } }); }
public IActionResult Index() { Dojo dojodachi = new Dojo(); HttpContext.Session.SetObjectAsJson("Dojo", dojodachi); return(View("Index", dojodachi)); }
public IActionResult Work() { Dojo get = HttpContext.Session.GetObjectFromJson <Dojo>("Dojo"); Random like = new Random(); Random meal = new Random(); if (get.Energy <= 0) { get.Message = "Your puppy doesnt have the energy to work have him take a nap so he can re energize."; } else { get.Energy -= 5; get.Meals += meal.Next(1, 3); get.Message = $"Your puppy put in work and has earned {meal.Next(1,3)} meals."; get.Image = "/images/Working.jpg"; } if (get.Happiness >= 100 && get.Fullness >= 100 && get.Energy >= 100) { get.Message = "Your a good pet owner. Congrats!"; get.Image = "/images/Working.jpg"; HttpContext.Session.SetObjectAsJson("Dojo", get); return(RedirectToAction("Success")); } else if (get.Happiness <= 0 || get.Fullness <= 0) { get.Message = "You kiled your puppy!! You bastard!!"; get.Image = "/images/Sad.jpg"; HttpContext.Session.SetObjectAsJson("Dojo", get); return(RedirectToAction("Failure")); } HttpContext.Session.SetObjectAsJson("Dojo", get); return(View("Index", get)); }
public ActionResult DeleteConfirmed(int id) { try { Dojo dojo = db.Dojos.Find(id); db.Dojos.Remove(dojo); db.SaveChanges(); return(RedirectToAction("Index")); } catch (DbUpdateException ex) { var sqlException = ex.GetBaseException() as SqlException; if (sqlException != null) { var number = sqlException.Number; if (number == 547) { return(Content("<script language='javascript' type='text/javascript'>alert('No se puede eliminar este Dojo. Esta relacionado con otras entidades!');window.history.back();</script>")); } } return(null); } }
public IActionResult Sleep() { Dojo get = HttpContext.Session.GetObjectFromJson <Dojo>("Dojo"); get.Energy += 15; get.Fullness -= 5; get.Happiness -= 5; get.Message = "Your puppy took a nap and gained 15 Energy but has lost 5 Fullness and Happiness"; get.Image = "/images/Sleeping.jpg"; if (get.Happiness >= 100 && get.Fullness >= 100 && get.Energy >= 100) { get.Message = "Your a good pet owner. Congrats!"; get.Image = "/images/Happy.jpg"; HttpContext.Session.SetObjectAsJson("Dojo", get); return(RedirectToAction("Success")); } else if (get.Happiness <= 0 || get.Fullness <= 0) { get.Message = "You kiled your puppy!! You bastard!!"; get.Image = "/images/Sad.jpg"; HttpContext.Session.SetObjectAsJson("Dojo", get); return(RedirectToAction("Failure")); } HttpContext.Session.SetObjectAsJson("Dojo", get); return(View("Index", get)); }
public IActionResult Sleep() { { Dojo get = HttpContext.Session.GetObjectFromJson <Dojo>("Dojo"); get.Energy += 15; get.Fullness -= 5; get.Happiness -= 5; get.Message = "Your DojoDachi has gained 15 Energy but has lost 5 Fullness and Happiness"; // get.Image = if (get.Happiness >= 100 && get.Fullness >= 100 && get.Energy >= 100) { get.Message = "You're a good pet owner. Congrats!"; // get.Image = HttpContext.Session.SetObjectAsJson("Dojo", get); return(RedirectToAction("Success")); } else if (get.Happiness <= 0 || get.Fullness <= 0) { get.Message = "You're a terrible owner, your dojodachi died"; // get.Image = HttpContext.Session.SetObjectAsJson("Dojo", get); return(RedirectToAction("Failure")); } HttpContext.Session.SetObjectAsJson("Dojo", get); return(View("Index", get)); } }
public IActionResult Play() { System.Console.WriteLine("playing"); Dojo dachi = HttpContext.Session.GetObjectFromJson <Dojo>("Dojodachi"); Random rand = new Random(); if (dachi.Energy == 0) { System.Console.WriteLine("out of energy...."); HttpContext.Session.SetString("log", "Your Dachi needs a rest. He has no more energy"); } else { dachi.Energy -= 5; if (rand.Next(1, 4) == 1) { HttpContext.Session.SetString("log", "Your Dachi is just going to chill"); } else { int newHappiness = rand.Next(5, 11); dachi.Happiness += newHappiness; HttpContext.Session.SetString("log", $"Your Dachi gained {newHappiness} happiness!"); } HttpContext.Session.SetObjectAsJson("Dojodachi", dachi); } return(RedirectToAction("Index")); }
public IActionResult dojodachi() { if (HttpContext.Session.GetInt32("fullness") == null) { Dojo temp = new Dojo(); HttpContext.Session.SetInt32("fullness", temp.fullness); HttpContext.Session.SetInt32("happiness", temp.happiness); HttpContext.Session.SetInt32("energy", temp.energy); HttpContext.Session.SetInt32("meals", temp.meals); HttpContext.Session.SetString("message", temp.message); ViewBag.fullness = temp.fullness; ViewBag.happiness = temp.happiness; ViewBag.energy = temp.energy; ViewBag.meals = temp.meals; ViewBag.message = temp.message; } else { int? full = HttpContext.Session.GetInt32("fullness"); int? happ = HttpContext.Session.GetInt32("happiness"); int? ene = HttpContext.Session.GetInt32("energy"); int? mea = HttpContext.Session.GetInt32("meals"); string mess = HttpContext.Session.GetString("message"); ViewBag.fullness = full; ViewBag.happiness = happ; ViewBag.energy = ene; ViewBag.meals = mea; ViewBag.message = mess; } return(View("Dojo")); }
public IActionResult Work() { Dojo get = HttpContext.Session.GetObjectFromJson <Dojo>("Dojo"); Random like = new Random(); Random work = new Random(); if (get.Energy <= 4) { get.Message = "You can't work"; } else { get.Happiness -= 5; get.Meal += work.Next(1, 3); get.Message = $"Your dojodachi earned {work.Next(1, 3)} meals"; // get.Image = } if (get.Fullness >= 100 && get.Happiness >= 100 && get.Energy >= 100) { get.Message = "You're a pro dojodachi owner, you win!"; HttpContext.Session.SetObjectAsJson("Dojo", get); return(RedirectToAction("Success")); } else if (get.Happiness <= 0 || get.Energy <= 0) { get.Message = "You're a terrible owner, your dojodachi died"; HttpContext.Session.SetObjectAsJson("Dojo", get); return(RedirectToAction("Death")); } HttpContext.Session.SetObjectAsJson("Dojo", get); return(View("Index", get)); }
public IActionResult Index() { List <Dojo> Dojos = _context.Dojos.ToList(); Dojo newDojo = new Dojo() { Name = "Tulsa" }; _context.Add(newDojo); _context.SaveChanges(); Dojo lastDojo = _context.Dojos.Where(dojo => dojo.Id == 1).SingleOrDefault(); Ninja ninja = new Ninja() { Name = "Phil", Dojo = lastDojo }; lastDojo.Ninjas.Add(ninja); _context.Add(ninja); _context.SaveChanges(); return(View()); }
public IActionResult ShowDojo(int dojo_id) { Dojo theDojo = _context.Dojos.Include(d => d.Ninjas).Where(d => d.Id == dojo_id).SingleOrDefault(); ViewBag.RogueNinjas = _context.Ninjas.Where(n => n.DojoId == 2).ToList(); return(View(theDojo)); }
public IActionResult SleepingDojo() { Dojo dojodachi = MakeDojos.GetDojoDachi(HttpContext); dojodachi.Sleep(); MakeDojos.SetDojoDachi(HttpContext, dojodachi); return(RedirectToAction("Index")); }
public User CreateDojoWithId(Guid dojoId) { var newDojo = new Dojo(dojoId, this); DojosCreated.Add(newDojo); DomainEvents.Raise(new UserCreatedDojo(Id, dojoId)); return(this); }
public void Add(Dojo item) { using (IDbConnection dbConnection = Connection) { string query = "INSERT INTO dojos (name, location, information) VALUES (@name, @location, @information)"; dbConnection.Open(); dbConnection.Execute(query, item); } }
public IActionResult NewGame() { Dojo dojodachi = MakeDojos.GetDojoDachi(HttpContext); dojodachi.Reset(); MakeDojos.SetDojoDachi(HttpContext, dojodachi); return(RedirectToAction("Index")); }
public void Create(Dojo dojo) { using (IDbConnection db = Connection) { string query = "INSERT INTO dojos (name, location, information) VALUES (@name, @location, @information)"; db.Open(); db.Execute(query, dojo); } }
public void Add(Dojo item) { using (IDbConnection dbConnection = Connection){ string query = "INSERT INTO dojos (Name, Location, Description) VALUES (@Name, @Location, @Description)"; dbConnection.Open(); dbConnection.Execute(query, item); } }
public void AddDojo(Dojo dojo) { using (IDbConnection dbConnection = Connection) { string sql = @"INSERT INTO dojos (name,location,info) VALUES (@name,@location,@info)"; dbConnection.Execute(sql, dojo); } }
public IActionResult WerkWerk() { Dojo dojodachi = MakeDojos.GetDojoDachi(HttpContext); dojodachi.Work(); MakeDojos.SetDojoDachi(HttpContext, dojodachi); return(RedirectToAction("Index")); }
public void Add(Dojo dojo) { using (IDbConnection dbConnection = Connection) { string query = "INSERT INTO dojos (name, location, description, created_at, updated_at) VALUES (@Name, @Location, @Description, @Created_At, @Updated_At)"; dbConnection.Open(); dbConnection.Execute(query, dojo); } }
public void AddDojo(Dojo dojo) { using (Connection) { var queryString = "INSERT INTO dojos(name, location, description) VALUES(@name, @location, @description)"; var result = Connection.Execute(queryString, dojo); } }
public void AddDojo(Dojo dojo) { using (IDbConnection dbConnection = Connection) { var query = "INSERT INTO dojos (name,location,description,created_at,updated_at) VALUES(@name,@location,@description,NOW(),NOW())"; dbConnection.Open(); dbConnection.Execute(query, dojo); } }
public void AddDojo(Dojo dojo) { using (IDbConnection dbConnection = Connection) { dbConnection.Open(); string query = "INSERT INTO dojos (name, location, info) VALUES (@name, @location, @info)"; dbConnection.Execute(query, dojo); } }
public IActionResult AddDojo(Dojo dojo) { dojoFactory = new DojoFactory(); TryValidateModel(dojo); ViewBag.Error = ModelState; dojoFactory.AddDojo(dojo); return(RedirectToAction("Dojos")); }
// create dojo public void CreateDojo(Dojo dojo) { using (IDbConnection dbConnection = Connection) { string query = "INSERT INTO dojos (DojoName, DojoLocation, DojoDescription, CreatedAt, UpdatedAt) VALUES(@DojoName, @DojoLocation, @DojoDescription, NOW(), NOW());"; dbConnection.Open(); dbConnection.Execute(query, dojo); } }
// Register dojo. public void RegisterDojo(Dojo dojo) { using (IDbConnection dbConnection = Connection) { dbConnection.Open(); string query = $"INSERT INTO dojos (name, location) VALUES (@name, @location)"; dbConnection.Execute(query, dojo); } }
public IActionResult AddDojo(Dojo dojo) { if (ModelState.IsValid) { _dojofactory.Add(dojo); return(RedirectToAction("Dojos")); } return(View("Dojos")); }
public static void AddNewDojo(Dojo dojo) { using (IDbConnection dbConnection = Connection) { string query = $" INSERT INTO dojos (name,location,info) VALUES('{dojo.name}','{dojo.location}','{dojo.info}')"; dbConnection.Open(); dbConnection.Execute(query); } }
ast.Node Error(ast.Part part) { Dojo.Error(part.identity, "Not found: " + part.ToString() + " in: " + context.ToString()); foreach (var candidate in list) { Dojo.Error(candidate, "\tCandidate: " + candidate.name); } return(ast.Node.nil); }
public IActionResult AddDojo(Dojo dojo) { if (ModelState.IsValid) { _userFactory.AddDojo(dojo); } ViewBag.dojos = _userFactory.GetDojos(); return(View("Dojos", dojo)); }
public Implemento(int id_implemento, String nombre_implemento, String tipo_implemento, String marca_implemento, String color_implemento, String talla_implemento, String imagen_implemento, int cantidad_implemento, int stock_minimo_implemento, String estatus_implemento, double precio_implemento, String descripcion_implemento, Dojo dojo) { this.id_implemento = id_implemento; this.nombre_implemento = nombre_implemento; this.tipo_implemento = tipo_implemento; this.marca_implemento = marca_implemento; this.color_implemento = color_implemento; this.talla_implemento = talla_implemento; this.imagen_implemento = imagen_implemento; this.stock_minimo_implemento = stock_minimo_implemento; this.estatus_implemento = estatus_implemento; this.cantidad_implemento = cantidad_implemento; this.descripcion_implemento = descripcion_implemento; this.precio_implemento = precio_implemento; this.dojo = dojo; }