public IHttpActionResult PutSEMESTER(int id, SEMESTER sEMESTER) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != sEMESTER.SEM_ID) { return(BadRequest()); } db.Entry(sEMESTER).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SEMESTERExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public bool updatesemester(SEMESTER semester) { var model = db.SEMESTERs.Find(semester.ID); model.TITLE = semester.TITLE; model.DESCRIPTION = semester.DESCRIPTION; model.START = semester.START; model.START = semester.END_SEM; db.SaveChanges(); return(true); }
public IHttpActionResult GetSEMESTER(int id) { SEMESTER sEMESTER = db.SEMESTERs.Find(id); if (sEMESTER == null) { return(NotFound()); } return(Ok(sEMESTER)); }
public ActionResult Index() { CommonFunc cf = new CommonFunc(); SemesterDAO semDao = new SemesterDAO(); SEMESTER sem = semDao.GetSemesterByID(cf.GetIdSemesterBySession()); UserDAO userDao = new UserDAO(); Session["UserName"] = userDao.GetUserByID(cf.GetIdUserBySession()).FIRST_NAME; return(View(sem)); }
public IHttpActionResult PostSEMESTER(SEMESTER sEMESTER) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SEMESTERs.Add(sEMESTER); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = sEMESTER.SEM_ID }, sEMESTER)); }
public Semester UpdateSemester(int id, SEMESTER name) { Semester semester = db.SemesterRepository.GetByID(id); if (semester != null) { semester.Name = name; db.SemesterRepository.Update(semester); db.Save(); } return(semester); }
public void AddNewSemester(SEMESTER newSemester) { SqlConnection con = GeneralMethods.ConnectToDatabase(); SqlCommand command = new SqlCommand("INSERT INTO [SEMESTER] (Semester_Name, Max_Units, Schoolyear, UserID) VALUES (@Semester_Name, @Max_Units, @Schoolyear, @UserID)", con); command.Parameters.AddWithValue("@Semester_Name", newSemester.SemesterName); command.Parameters.AddWithValue("@Max_Units", newSemester.MaxUnits); command.Parameters.AddWithValue("@Schoolyear", newSemester.Schoolyear); command.Parameters.AddWithValue("@UserID", ViewModelLocator.MainWindowViewModel.SelectedUser.UserID); command.ExecuteNonQuery(); con.Close(); GetAndDisplaySemesters(); }
public IHttpActionResult DeleteSEMESTER(int id) { SEMESTER sEMESTER = db.SEMESTERs.Find(id); if (sEMESTER == null) { return(NotFound()); } db.SEMESTERs.Remove(sEMESTER); db.SaveChanges(); return(Ok(sEMESTER)); }
public JsonResult Save(SEMESTER semester) { bool status = false; string message = string.Empty; if (semester.ID != "0") { try { var model = new SemesterDAO().updatesemester(semester); status = true; } catch (Exception ex) { status = false; message = ex.Message; } } else { try { semester.ID = createID("SEME"); db.SEMESTERs.Add(semester); db.SaveChanges(); status = true; } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); raise = new InvalidOperationException(message, raise); } } throw raise; } } return(Json(new { status = status, message = message })); }
private void BtnOpenAddSemester_Click(object sender, RoutedEventArgs e) { var window = new AddSemesterWindow(); window.Owner = this; window.WindowStartupLocation = WindowStartupLocation.CenterOwner; SEMESTER newSemester = new SEMESTER(); window.DataContext = newSemester; var result = window.ShowDialog(); if (result == true) { ViewModelLocator.SemesterSelectViewModel.AddNewSemester(newSemester); } }
public List <COURSE> courseinsemester(string id) { SEMESTER semester = db.SEMESTERs.Where(a => a.ID == id).FirstOrDefault(); List <COURSE> course = semester.COURSEs.Select(b => new COURSE { ID = b.ID, NAME = b.NAME, DESCRIPTION = b.DESCRIPTION, TEACH = (b.TEACH == null) ? null : (new TEACH { C_USER = (b.TEACH.C_USER == null) ? null : (new C_USER { ID = (b.TEACH.C_USER.ID == null) ? null : (b.TEACH.C_USER.ID), FIRST_NAME = (b.TEACH.C_USER.FIRST_NAME == null) ? null : (b.TEACH.C_USER.FIRST_NAME), LAST_NAME = (b.TEACH.C_USER.LAST_NAME == null) ? null : (b.TEACH.C_USER.LAST_NAME), MIDDLE_NAME = (b.TEACH.C_USER.MIDDLE_NAME == null) ? null : (b.TEACH.C_USER.MIDDLE_NAME), }) }), }).ToList(); return(course); }
public List <COURSE> GetCourseInSemester(string id_sem) { SEMESTER sem = db.SEMESTERs.Where(a => a.ID == id_sem).FirstOrDefault(); List <COURSE> course = sem.COURSEs.Select(b => new COURSE { ID = b.ID, NAME = b.NAME, DESCRIPTION = b.DESCRIPTION, TEACH = new TEACH { C_USER = new C_USER { ID = b.TEACH.C_USER.ID, FIRST_NAME = b.TEACH.C_USER.FIRST_NAME, LAST_NAME = b.TEACH.C_USER.LAST_NAME, MIDDLE_NAME = b.TEACH.C_USER.MIDDLE_NAME, } } }).ToList(); return(course); }
private void GetAndDisplaySemesters() { ListSemesters.Clear(); SqlConnection con = GeneralMethods.ConnectToDatabase(); SqlDataAdapter sda2 = new SqlDataAdapter("SELECT * From [SEMESTER] WHERE UserID='" + ViewModelLocator.MainWindowViewModel.SelectedUser.UserID + "'", con); DataTable dt = new DataTable(); sda2.Fill(dt); con.Close(); for (int x = 0; x < dt.Rows.Count; x++) { SEMESTER newSemester = new SEMESTER(); newSemester.SemesterName = dt.Rows[x]["Semester_Name"].ToString(); newSemester.MaxUnits = Convert.ToInt16(dt.Rows[x]["Max_Units"]); newSemester.Schoolyear = dt.Rows[x]["Schoolyear"].ToString(); newSemester.SemID = Convert.ToInt16(dt.Rows[x]["SemID"]); ListSemesters.Add(newSemester); } }
public Semester(int id, SEMESTER name) { Id = id; Name = name; }
public bool addsemester(SEMESTER semester) { db.SEMESTERs.Add(semester); db.SaveChanges(); return(true); }