public async Task <IActionResult> PutClassScheduler([FromRoute] int id, [FromBody] ClassScheduler classScheduler) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != classScheduler.Id) { return(BadRequest()); } _context.Entry(classScheduler).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClassSchedulerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostClassScheduler([FromBody] ClassScheduler classScheduler) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ClassScheduler.Add(classScheduler); await _context.SaveChangesAsync(); return(CreatedAtAction("GetClassScheduler", new { id = classScheduler.Id }, classScheduler)); }
protected void gvBatches_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { e.Cancel = true; ClassScheduler bs = new ClassScheduler(); bs.ID = int.Parse(e.Keys["ID"].ToString()); bs.IA = int.Parse(Session["Testscores"].ToString()); bs.Timetable = int.Parse(Session["Timetable"].ToString()); bs.Registration = int.Parse(Session["Registration"].ToString()); bs.Exams = int.Parse(Session["Examsscore"].ToString()); bs.ModifyDate = DateTime.Now; if (new ClassSchedulerServices().UpdateClassSchedulerActivity(bs, new SessionManager().GetUserId(this.Session))) { ScriptManager.RegisterStartupScript(this, GetType(), ",toastr", "toastr.success('Saved Successfully','Message')", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), ",toastr", "toastr.error('Oops something is not right! Saving Failed','Message')", true); } loadBatches(); uPanel.Update(); }
protected void btnSaveClassSchedule_Click(object sender, EventArgs e) { if (!validateInputs()) { uPanel.Update(); return; } ClassScheduler classABC = new ClassScheduler(); classABC.Term = cmbTerms.Text.ToString(); classABC.AcademicYear = txtAcademicYear.Text; classABC.ClassSize = int.Parse(spnSize.Value.ToString()); classABC.ModifyDate = DateTime.Now; classABC.CreatedDate = DateTime.Now; classABC.BgsId = int.Parse(cmbGradSystem.Value.ToString()); string classLessons = ""; if (txtId.Text == "0") { //CKECKING IF THE CLASS SCHEDULE IS ALREADY CREATED FOR THIS START AND END DATE TO CREATE SPERTE CLASSES FOR THE SAME DATE PERIOD classABC.ClassID = int.Parse(cmbProgram.GridView.GetRowValues(cmbProgram.GridView.FocusedRowIndex, "ID").ToString()); string groups = new ClassSchedulerServices().NumberingClassScheduler(classABC, new SessionManager().GetUserId(Session)); classABC.Title = cmbProgram.GridView.GetRowValues(cmbProgram.GridView.FocusedRowIndex, "Title") + " : " + cmbTerms.Text + " - " + txtAcademicYear.Text + " GROUP " + groups; classABC.ModuleID = int.Parse(cmbProgram.GridView.GetRowValues(cmbProgram.GridView.FocusedRowIndex, "ModuleID").ToString()); string yrgroup = new ClassSchedulerServices().GroupClassScheduler(classABC, new SessionManager().GetUserId(Session)); if (yrgroup == "") { classABC.Bgroup = new UserService().GenerateUserID(); } else { classABC.Bgroup = yrgroup; } //POPULATE THE LESSON SCHEDULER TABLE List <Lesson> allLessons = new LessonService().GetAllLessonsByClassID(int.Parse(cmbProgram.GridView.GetRowValues(cmbProgram.GridView.FocusedRowIndex, "ID").ToString()), new SessionManager().GetUserId(Session)); if (allLessons.Count > 0) { if (new ClassSchedulerServices().AddClassScheduler(classABC, new SessionManager().GetUserId(Session))) { //bool addClasses = new ClassSchedulerServices().AddClassScheduler(classABC, new SessionManager().GetUserId(Session)); foreach (Lesson allLesson in allLessons) { LessonScheduler l = new LessonScheduler(); int ClassID = int.Parse(cmbProgram.GridView.GetRowValues(cmbProgram.GridView.FocusedRowIndex, "ID").ToString()); int ModuleID = int.Parse(cmbProgram.GridView.GetRowValues(cmbProgram.GridView.FocusedRowIndex, "ModuleID").ToString()); int ClassScheID = new ClassSchedulerServices().GetLastClassScheduleID(new SessionManager().GetUserId(Session)); int LessonID = allLesson.ID; classLessons += "('" + ClassScheID + "','" + ModuleID + "','" + ClassID + "','" + LessonID + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'),"; } if (new LessonSchedulerServices().AddLessonSchedulerList(classLessons.TrimEnd(','), new SessionManager().GetUserId(Session))) { clearfields(); ScriptManager.RegisterStartupScript(this, GetType(), ",toastr", "toastr.success('Saved Successfully','Message')", true); } } else { ScriptManager.RegisterStartupScript(this, GetType(), ",toastr", "toastr.info('Add Courses to this Program before creating a Batch','Message')", true); } } else { ScriptManager.RegisterStartupScript(this, GetType(), ",toastr", "toastr.info('Add Courses to this Program before creating a Batch','Message')", true); } } else { classABC.ID = int.Parse(txtId.Text); classABC.Title = txtDesc.Text; classABC.ModuleID = int.Parse(txtModuleID.Text); classABC.ClassID = int.Parse(txtClassID.Text); if (new ClassSchedulerServices().UpdateClassScheduler(classABC, new SessionManager().GetUserId(Session))) { clearfields(); ScriptManager.RegisterStartupScript(this, GetType(), ",toastr", "toastr.success('Updated Successfully','Message')", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), ",toastr", "toastr.error('Updating Failed','Message')", true); } } loadPrograms(); uPanel.Update(); }