public ActionResult Create(TrainerQuery trainerquery) { if (ModelState.IsValid) { db.TrainerQueries.Add(trainerquery); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.UserId = new SelectList(db.Users, "UserId", "UserName", trainerquery.UserId); return View(trainerquery); }
public ActionResult Index(int id,string why) { if (!TrainerQueryDAL.queryExist(User.Identity.Name)) { ModelState.AddModelError(String.Empty, "Вече си подал заявка"); } if (ModelState.IsValid) { TrainerQuery data = new TrainerQuery(); data.UserId = UsersDAL.getUserId(User.Identity.Name); data.Why = why; db.TrainerQueries.Add(data); db.SaveChanges(); return Redirect("/"); } else { return View(); } }
public ActionResult Edit(TrainerQuery trainerquery) { if (ModelState.IsValid) { db.Entry(trainerquery).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.UserId = new SelectList(db.Users, "UserId", "UserName", trainerquery.UserId); return View(trainerquery); }