public ActionResult DeleteConfirmed(int id) { TrainerAssign trainerAssign = db.TrainerAssigns.Find(id); db.TrainerAssigns.Remove(trainerAssign); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TrainerAssignID,TopicID,TrainerID,Year")] TrainerAssign trainerAssign) { if (ModelState.IsValid) { db.Entry(trainerAssign).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TopicID = new SelectList(db.Topics, "TopicID", "TopicName", trainerAssign.TopicID); ViewBag.TrainerID = new SelectList(db.Trainers, "TrainerID", "TrainerName", trainerAssign.TrainerID); return(View(trainerAssign)); }
// GET: TrainerAssigns/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TrainerAssign trainerAssign = db.TrainerAssigns.Find(id); if (trainerAssign == null) { return(HttpNotFound()); } return(View(trainerAssign)); }
// GET: TrainerAssigns/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TrainerAssign trainerAssign = db.TrainerAssigns.Find(id); if (trainerAssign == null) { return(HttpNotFound()); } ViewBag.TopicID = new SelectList(db.Topics, "TopicID", "TopicName", trainerAssign.TopicID); ViewBag.TrainerID = new SelectList(db.Trainers, "TrainerID", "TrainerName", trainerAssign.TrainerID); return(View(trainerAssign)); }
//[Authorize(Roles = "Admin")] public ActionResult AssignTrainer(TrainerAssign TrainerAssign, string BranchCode, string TrainerId, string JoiningDate, string LeavingDate, Int64 TrainerAssignId = 0) { string UserId = User.Identity.GetUserId(); var UserDetails = generic.GetUserDetail(UserId); ViewData["UserProfile"] = UserDetails; if (!String.IsNullOrEmpty(JoiningDate)) { TrainerAssign.DateOfJoining = DateTime.ParseExact(JoiningDate, "dd-MM-yyyy", CultureInfo.InvariantCulture); } if (!String.IsNullOrEmpty(LeavingDate)) { TrainerAssign.LeavingDate = DateTime.ParseExact(LeavingDate, "dd-MM-yyyy", CultureInfo.InvariantCulture); } bool result = rms.AddTrainer(TrainerAssignId, BranchCode, TrainerId, TrainerAssign.DateOfJoining, TrainerAssign.LeavingDate); return(RedirectToAction("AssignTrainer", "RMS", new { Area = "RMS", status = result })); }
public ActionResult Create([Bind(Include = "TrainerAssignID,TopicID,TrainerID,Year")] TrainerAssign trainerAssign) { if (ModelState.IsValid) { try { db.TrainerAssigns.Add(trainerAssign); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("", "ID is already existed! "); return(View(trainerAssign)); } } ViewBag.TopicID = new SelectList(db.Topics, "TopicID", "TopicName", trainerAssign.TopicID); ViewBag.TrainerID = new SelectList(db.Trainers, "TrainerID", "TrainerName", trainerAssign.TrainerID); return(View(trainerAssign)); }