public async Task <ActionResult> Delete(int?id) { if (Session["UserID"] != null) { if (Session["User_role"].ToString() != "Administrator") { return(HttpNotFound()); } ViewBag.ActiveTrainingAndSeminarListTrainingAndSeminar = "class = active"; ViewBag.ActiveTreeTrainingAndSeminar = "active"; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TrainingSeminar trainingseminar = await db.TrainingSeminars.FindAsync(id); if (trainingseminar == null || trainingseminar.deleted != false) { return(HttpNotFound()); } return(View(trainingseminar)); } else { return(RedirectToAction("Login", "Account")); } }
public async Task <ActionResult> Edit([Bind(Include = "ts_id,updated_on,updated_by,title,nature,sponsor,location,date_start,date_end,ts_level,number_of_hours")] TrainingSeminar trainingseminar) { var current_trainingseminar = db.TrainingSeminars.FirstOrDefault(ts => ts.ts_id == trainingseminar.ts_id); if (current_trainingseminar == null) { return(HttpNotFound()); } current_trainingseminar.updated_on = DateTime.Now; current_trainingseminar.updated_by = Session["User_firstname"].ToString() + " " + Session["User_middlename"].ToString() + " " + Session["User_lastname"].ToString(); current_trainingseminar.title = trainingseminar.title; current_trainingseminar.nature = trainingseminar.nature; current_trainingseminar.sponsor = trainingseminar.sponsor; current_trainingseminar.location = trainingseminar.location; current_trainingseminar.date_start = trainingseminar.date_start; current_trainingseminar.date_end = trainingseminar.date_end; current_trainingseminar.ts_level = trainingseminar.ts_level; current_trainingseminar.number_of_hours = trainingseminar.number_of_hours; await db.SaveChangesAsync(); TempData["t_ts"] = "updated"; return(RedirectToAction("Index")); }
public void TranslateTrainingSeminarToTrainingSeminarBDO(TrainingSeminar tc, TrainingSeminarBDO tcbdo) { tcbdo.AreaOfTraining = tc.AreaOfTraining; tcbdo.ConductedBy = tc.ConductedBy; tcbdo.DateFrom = tc.DateFrom; tcbdo.DateTo = tc.DateTo; tcbdo.NoOfHours = tc.NoOfHours; tcbdo.TeacherId = tc.TeacherId; tcbdo.Title = tc.Title; tcbdo.TSID = tc.TSID; }
public List <TrainingSeminar> ToTrainSemDTO(List <TrainingSeminarBDO> teb) { List <TrainingSeminar> tebdoList = new List <TrainingSeminar>(); foreach (TrainingSeminarBDO t in teb) { TrainingSeminar tebdo = new TrainingSeminar(); TranslateTrainingSeminarBDOToTrainingSeminarDTO(t, tebdo); tebdoList.Add(tebdo); } return(tebdoList); }
public async Task <ActionResult> DeleteConfirmed(int id) { TrainingSeminar trainingseminar = await db.TrainingSeminars.FindAsync(id); trainingseminar.deleted = true; trainingseminar.updated_on = DateTime.Now; trainingseminar.updated_by = Session["User_firstname"].ToString() + " " + Session["User_middlename"].ToString() + " " + Session["User_lastname"].ToString(); await db.SaveChangesAsync(); TempData["t_ts"] = "deleted"; return(RedirectToAction("Index")); }
public async Task <ActionResult> Create([Bind(Include = "ts_id,date_created,created_by,title,nature,sponsor,location,date_start,date_end,ts_level,number_of_hours")] TrainingSeminar trainingseminar) { if (ModelState.IsValid) { TrainingSeminar new_trainingseminar = new TrainingSeminar(); new_trainingseminar.date_created = DateTime.Now; new_trainingseminar.created_by = Session["User_firstname"].ToString() + " " + Session["User_middlename"].ToString() + " " + Session["User_lastname"].ToString(); new_trainingseminar.title = trainingseminar.title; new_trainingseminar.nature = trainingseminar.nature; new_trainingseminar.sponsor = trainingseminar.sponsor; new_trainingseminar.location = trainingseminar.location; new_trainingseminar.date_start = trainingseminar.date_start; new_trainingseminar.date_end = trainingseminar.date_end; new_trainingseminar.ts_level = trainingseminar.ts_level; new_trainingseminar.number_of_hours = trainingseminar.number_of_hours; db.TrainingSeminars.Add(new_trainingseminar); TempData["t_ts"] = "added"; await db.SaveChangesAsync(); } return(RedirectToAction("Index")); }