public ProgrammeCourse UpdateProgrammeCourse(ProgrammeCourse _programmeCourse) { var progCourse = dbContext.ProgrammeCourses.Attach(_programmeCourse); progCourse.State = Microsoft.EntityFrameworkCore.EntityState.Modified; dbContext.SaveChanges(); return(_programmeCourse); }
public ProgrammeCourse RemoveProgrammeCourse(Guid Id) { ProgrammeCourse programmeCourse = dbContext.ProgrammeCourses.Find(Id); if (programmeCourse != null) { dbContext.ProgrammeCourses.Remove(programmeCourse); dbContext.SaveChanges(); } return(programmeCourse); }
public bool UpdateProgrammeCourse(long programmeCourseId, ProgrammeCourse programmeCourse) { try { return(programmeCourseId > 0 && programmeCourse != null && _programmeCourseRepository.UpdateProgrammeCourse(programmeCourseId, programmeCourse)); } catch (Exception e) { return(false); } }
public bool CreateProgrammeCourse(ProgrammeCourse programmeCourse) { try { return(programmeCourse != null && _programmeCourseRepository.CreateProgrammeCourse(programmeCourse)); } catch (Exception e) { return(false); } }
public IActionResult AllocateCourses(ProgramCourseViewModel model) { var Selected = model.AcadaCourseId; int modelProgramId = model.AcadaProgId; foreach (var item in Selected) { ProgrammeCourse pc = new ProgrammeCourse() { AcademyProgramId = modelProgramId, CoursesId = int.Parse(item) }; _programmes.AddProgCourses(pc); } return(RedirectToAction("ListProgram")); }
public ProgrammeCourse AddProgrammeCourse(ProgrammeCourse _programmeCourse) { dbContext.ProgrammeCourses.Add(_programmeCourse); dbContext.SaveChanges(); return(_programmeCourse); }
public async Task <IActionResult> ManageProgrammeCourses(List <ProgramCoursesViewModel> model, int id) { var data = new ProgrammeCourse(); foreach (var item in model) { var included = false; //var courses = _employeeRepository.GetProgrammeCourses(id); var courses = _db.ProgrammeCourses.Where(c => c.ProgrammeId == id); if (item.IsSelected) { if (courses.Count() > 0) { foreach (var course in courses) { if (course.CourseId == item.CourseId && course.ProgrammeId == id) { included = true; } } if (!included) { data = new ProgrammeCourse { CourseId = item.CourseId, ProgrammeId = id }; _db.ProgrammeCourses.Add(data); await _db.SaveChangesAsync(); } } else { data = new ProgrammeCourse { CourseId = item.CourseId, ProgrammeId = id }; _db.ProgrammeCourses.Add(data); await _db.SaveChangesAsync(); } } else { if (courses.Count() > 0) { foreach (var course in courses) { if (course.CourseId == item.CourseId && course.ProgrammeId == id) { included = true; } } if (included) { data = new ProgrammeCourse { CourseId = item.CourseId, ProgrammeId = id }; //_db.ProgrammeCourses.Where(pc => pc.ProgrammeId == id && pc.CourseId == data.CourseId); var l = _db.ProgrammeCourses.ToList(); for (int i = 0; i < l.Count; i++) { if (l[i].ProgrammeId == id && l[i].CourseId == item.CourseId) { _db.Remove(l[i]); _db.SaveChanges(); } } await _db.SaveChangesAsync(); } } } } return(RedirectToAction("Details", new { id = id })); }