private WheelsService CreateWheelsService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new WheelsService(userId); return(service); }
public ActionResult Edit(int id) { var service = CreateBuildService(); var detail = service.GetBuildById(id); var userId = Guid.Parse(User.Identity.GetUserId()); CarService serviceCar2 = new CarService(userId); ViewBag.Cars = serviceCar2.GetCars(); DecalService serviceDecal2 = new DecalService(userId); ViewBag.Decals = serviceDecal2.GetDecals(); WheelsService serviceWheels2 = new WheelsService(userId); ViewBag.Wheelss = serviceWheels2.GetWheels(); GoalService serviceGoal2 = new GoalService(userId); ViewBag.Goals = serviceGoal2.GetGoals(); var model = new BuildEdit { BuildID = detail.BuildID, BuildName = detail.BuildName, }; return(View(model)); }
public ActionResult Create(BuildCreate model) { var userId = Guid.Parse(User.Identity.GetUserId()); CarService serviceCar = new CarService(userId); ViewBag.Cars = serviceCar.GetCars(); DecalService serviceDecal = new DecalService(userId); ViewBag.Decals = serviceDecal.GetDecals(); WheelsService serviceWheels = new WheelsService(userId); ViewBag.Wheelss = serviceWheels.GetWheels(); GoalService serviceGoal = new GoalService(userId); ViewBag.Goals = serviceGoal.GetGoals(); if (!ModelState.IsValid) { return(View(model)); } var service = CreateBuildService(); if (service.CreateBuild(model)) { TempData["SaveResult"] = "Your build was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Build could not be created."); return(View(model)); }
// GET: Wheels public ActionResult Index() { var userID = Guid.Parse(User.Identity.GetUserId()); var service = new WheelsService(userID); var model = service.GetWheels(); return(View(model)); }
//GET public ActionResult Create() { var userId = Guid.Parse(User.Identity.GetUserId()); CarService serviceCar = new CarService(userId); ViewBag.Cars = serviceCar.GetCars(); DecalService serviceDecal = new DecalService(userId); ViewBag.Decals = serviceDecal.GetDecals(); WheelsService serviceWheels = new WheelsService(userId); ViewBag.Wheelss = serviceWheels.GetWheels(); GoalService serviceGoal = new GoalService(userId); ViewBag.Goals = serviceGoal.GetGoals(); return(View()); }
public ActionResult Edit(int id, BuildEdit model) { var service = CreateBuildService(); var detail = service.GetBuildById(id); var userId = Guid.Parse(User.Identity.GetUserId()); CarService serviceCar2 = new CarService(userId); ViewBag.Cars = serviceCar2.GetCars(); DecalService serviceDecal2 = new DecalService(userId); ViewBag.Decals = serviceDecal2.GetDecals(); WheelsService serviceWheels2 = new WheelsService(userId); ViewBag.Wheelss = serviceWheels2.GetWheels(); GoalService serviceGoal2 = new GoalService(userId); ViewBag.Goals = serviceGoal2.GetGoals(); if (!ModelState.IsValid) { return(View(model)); } if (model.BuildID != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service2 = CreateBuildService(); if (service2.UpdateBuild(model)) { TempData["SaveResult"] = "Your build was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your build could not be updated."); return(View(model)); }