public ActionResult DeleteExActivity(int Teacherid, string Schoolid, string Activitycode) { ExtraActivityModel TModel = new ExtraActivityModel(); TModel.TeacherID = Teacherid; TModel.SchoolId = Schoolid; TModel.ActivityCode = Activitycode; return(PartialView("DeleteTeacherExActivity", TModel)); }
public ActionResult DeleteExActivity(ExtraActivityModel Model) { try { tblTeacherExtraCurricularActivity Tble = Connection.tblTeacherExtraCurricularActivities.Find (Model.TeacherID, Model.SchoolId, Model.ActivityCode); Connection.tblTeacherExtraCurricularActivities.Remove(Tble); Connection.SaveChanges(); return(Json(Model.TeacherID, JsonRequestBehavior.AllowGet)); } catch { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public JsonResult AddExtraActivity(ExtraActivityModel Model) { try { var count = Connection.tblTeacherExtraCurricularActivities.Count( u => u.TeacherId == Model.TeacherID && u.ActivityCode == Model.ActivityCode); if (count == 0) { tblTeacherExtraCurricularActivity NewQ = new tblTeacherExtraCurricularActivity(); NewQ.CreatedBy = _session.User_Id; NewQ.CreatedDate = DateTime.Now; NewQ.IsActive = "Y"; NewQ.ActivityCode = Model.ActivityCode; NewQ.SchoolId = _session.School_Id; NewQ.TeacherId = Model.TeacherID; Connection.tblTeacherExtraCurricularActivities.Add(NewQ); Connection.SaveChanges(); var result = new { Teacher_Id = Model.TeacherID, msg = "Success" }; return(Json(result, JsonRequestBehavior.AllowGet)); } else { var result = new { Teacher_Id = Model.TeacherID, msg = "Exits" }; return(Json(result, JsonRequestBehavior.AllowGet)); } } catch (Exception Ex) { Errorlog.ErrorManager.LogError("Teacher Controller - AddExtraActivity(ExtraActivityModel Model)", Ex); var result = new { Teacher_Id = Model.TeacherID, msg = "Exception" }; return(Json(result, JsonRequestBehavior.AllowGet)); } }