public ActionResult Edit(User user) { if (ModelState.IsValid) { context.Entry(user).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public ActionResult Create(User user) { if (ModelState.IsValid) { context.Users.Add(user); context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public ActionResult TestResource() { Resource resource = new Resource(); resource.amount = 0; resource.resourceType = context.ResourcesTypes.Where(rt=>rt.name == "wood").FirstOrDefault(); resource.increase = 10; Resource resource2 = new Resource(); resource2.amount = 0; resource2.resourceType = context.ResourcesTypes.Where(rt => rt.name == "metal").FirstOrDefault(); resource2.increase = 15; User user = new User(); user.name = "william"; user.password = "******"; user.resources = new List<Resource>(); user.resources.Add(resource); user.resources.Add(resource2); context.Users.Add(user); context.SaveChanges(); return JavaScript("alert('lol')"); }