public async Task Handle_should_enroll_student() { await using var dbContext = _fixture.BuildDbContext(); var student = new Student(Guid.NewGuid(), "student", "to enroll"); dbContext.Students.Add(student); var course = new Course(Guid.NewGuid(), "course"); dbContext.Courses.Add(course); await dbContext.SaveChangesAsync(); //dbContext.Entry(student).State = Microsoft.EntityFrameworkCore.EntityState.Detached; //dbContext.Entry(course).State = Microsoft.EntityFrameworkCore.EntityState.Detached; var studentsRepo = new StudentsRepository(dbContext); var coursesRepo = new CoursesRepository(dbContext); var messagesRepository = NSubstitute.Substitute.For <IMessagesRepository>(); var eventSerializer = NSubstitute.Substitute.For <IEventSerializer>(); var unitOfWork = new SchoolUnitOfWork(dbContext, coursesRepo, studentsRepo, messagesRepository, eventSerializer); var sut = new EnrollHandler(new FakeValidator <Enroll>(), unitOfWork); var command = new Enroll(course.Id, student.Id); await sut.Handle(command, CancellationToken.None); var loadedStudent = await dbContext.Students.FindAsync(student.Id); loadedStudent.Courses.Count.Should().Be(1); }
private void EnrollDetailForm_Load(object sender, EventArgs e) { txt_UserId.Text = user.DIN.ToString(); Enroll enroll = user.Enrolls[0]; SetPrivilege(); for (int i = 0; i < Zd2911Utils.MaxFingerprintCount; i++) { if (0 != Zd2911Utils.BitCheck((int)enroll.EnrollType, i)) { clb_Fp.SetItemChecked(i, true); } } if (0 != Zd2911Utils.BitCheck((int)enroll.EnrollType, 10)) { clb_Fp.SetItemChecked(10, true); } if (0 != Zd2911Utils.BitCheck((int)enroll.EnrollType, 11)) { clb_Fp.SetItemChecked(11, true); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,DeptId,CourseId,StudentId,Status")] Enroll enroll) { if (id != enroll.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enroll); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnrollExists(enroll.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(enroll)); }
public bool SetEnrollStudent(Enroll enroll) { GenarateConnection(); using (Connection) { Connection.Open(); string query = "insert into EnrollInACourse(StudentID,CourseID,Date) values (@StudentID,@CourseID,@Date);"; Command = new SqlCommand(query, Connection); Command.Parameters.Clear(); Command.Parameters.Add("@StudentID", SqlDbType.Int); Command.Parameters["@StudentID"].Value = enroll.ID; Command.Parameters.Add("@CourseID", SqlDbType.Int); Command.Parameters["@CourseID"].Value = enroll.CourseIDs; Command.Parameters.Add("@Date", SqlDbType.VarChar); Command.Parameters["@Date"].Value = enroll.Date; try { Command.ExecuteNonQuery(); Connection.Close(); return(true); } catch (Exception) { throw new Exception("Error While Entering data into database"); } } }
public async Task <IActionResult> Enroll([FromRoute] Guid id, [FromRoute] Guid courseId) { var command = new Enroll(courseId, id); await _mediator.Publish(command); return(Ok()); }
public async Task <IActionResult> Edit(int id, [Bind("ID,FormCode,Message,OriginMsg,HasSend,CreateDate,Creator")] Enroll enroll) { if (id != enroll.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enroll); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnrollExists(enroll.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(enroll)); }
public ActionResult Create(CombinedModel cm, Enroll en) { try { db.Students.Add(cm.ViewStudent); db.SaveChanges(); cm.ViewEnroll.StudentID = cm.ViewStudent.StudentId; cm.ViewEnroll.CourseID = (int)en.CourseID; db.Enrolls.Add(cm.ViewEnroll); db.SaveChanges(); cm.ViewInstallment.EnrollmentId = cm.ViewEnroll.EnrollId; db.Installments.Add(cm.ViewInstallment); db.SaveChanges(); // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { ViewBag.CourseID = new SelectList(db.Courses, "CourseId", "CourseName", cm.ViewEnroll.CourseID); return(View(cm)); } return(View("index")); }
public ActionResult Add(EnrollRegisterModel modelEnroll) { Student student = _studentRepository.GetById(modelEnroll.Id); List <AcademicYear> collection = _academicYearRepository.Filter(x => x.Grade.Id == modelEnroll.GradeId && x.Section.Equals(modelEnroll.Section)).ToList(); if (collection.Count > 0 && student != null) { foreach (AcademicYear academicYear in collection) { var myEnroll = new Enroll { AcademicYear = academicYear, Student = student }; _enrollRepository.Create(myEnroll); } const string title = "Estudiante Agregado"; const string content = "El estudiante ha sido matriculado exitosamente."; _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage); } else { const string title = "Estudiante No Agregado"; const string content = "El estudiante no se logro matricular."; _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage); } return(RedirectToAction("Index")); }
public void Calificar(Classmates notas) { Enroll matriculada = context.Enroll.Where(x => x.Course == notas.EnrollsNavigation.Course && x.Student == notas.EnrollsNavigation.Student).First(); Assign asignada = context.Assign.Where(x => x.Teacher == notas.AssignNavigation.Teacher && x.CourseId == notas.AssignNavigation.CourseId).First(); Classmates classmates = new Classmates() { Nota = notas.Nota, Enrolls = matriculada.Id, Assign = asignada.Id, Period = notas.Period, }; var datos = context.Classmates.Find(classmates.Assign, classmates.Enrolls, classmates.Period); if (datos != null) { datos.Nota = notas.Nota; context.Classmates.Update(datos); } else { context.Classmates.Add(classmates); } context.SaveChanges(); }
public async Task <ActionResult> Edit(int?id) { Enroll enroll = null; if (id.HasValue) { enroll = await _helper.GetEnroll(id.Value, false); } else { enroll = _helper.GetEnroll(); } if (enroll == null) { return(Redirect("/Mob")); } if (_helper.IsPaid(enroll)) { return(Redirect("/Mob/Enroll/Process")); } return(View("Index", enroll)); }
public ActionResult EnrollCourse(Enroll aEnroll) { EnrollManager aEnrollManager = new EnrollManager(); StudentManager aStudentManager = new StudentManager(); ViewBag.studentlist = aStudentManager.GetAllStudents(); var courselist = aEnrollManager.GetAllEnrollsByRegNo(aEnroll.StudentRegNo); var check = courselist.FirstOrDefault(a => a.CourseId == aEnroll.CourseId); var courselisttrue = aEnrollManager.GetAllEnrollsByRegNoTrue(aEnroll.StudentRegNo); var checktrue = courselisttrue.FirstOrDefault(a => a.CourseId == aEnroll.CourseId); if (aEnroll.CourseId == 0) { ViewBag.message = "Select Course"; } else { if (checktrue != null) { ViewBag.message = "This Course Already Assigned"; } else { aEnrollManager.EnrollCourse(aEnroll); ViewBag.message = "Course Enrolled Successfully"; } } return(View(aEnroll)); }
public bool IsStudentCourseExist(Enroll enroll) { bool result = false; GenarateConnection(); using (Connection) { string querys = "select * from EnrollInACourse where StudentID =@StudentId and CourseID=@CourseID ;"; Command = new SqlCommand(querys, Connection); Command.Parameters.Clear(); Connection.Open(); Command.Parameters.Add("@StudentId", SqlDbType.Int); Command.Parameters["@StudentId"].Value = enroll.ID; Command.Parameters.Add("@CourseID", SqlDbType.Int); Command.Parameters["@CourseID"].Value = enroll.CourseIDs; Reader = Command.ExecuteReader(); if (Reader.HasRows) { while (Reader.Read()) { result = true; } } Reader.Close(); Connection.Close(); } return(result); }
/// <summary> /// Enrolls a student in a class. /// </summary> /// <param name="subject">The department subject abbreviation</param> /// <param name="num">The course number</param> /// <param name="season">The season part of the semester</param> /// <param name="year">The year part of the semester</param> /// <param name="uid">The uid of the student</param> /// <returns>A JSON object containing {success = {true/false}. /// false if the student is already enrolled in the class, true otherwise.</returns> public IActionResult Enroll(string subject, int num, string season, int year, string uid) { var classID = getClassID(subject, num, season, year); // To see if the student has already enrolled in that class var query1 = from e in db.Enroll where e.ClassId == classID && e.StudentId == uid select e; // if he has already enrolled in the class, return false if (query1.Count() > 0) { return(Json(new { success = false })); } else // otherwise, create a new row { Enroll e = new Enroll(); e.StudentId = uid; e.ClassId = classID; e.Grade = "--"; db.Enroll.Add(e); db.SaveChanges(); return(Json(new { success = true })); } }
public async Task <IActionResult> Edit(int id, [Bind("EnrollId,CourseId,StudentAuId")] Enroll enroll) { if (id != enroll.EnrollId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enroll); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnrollExists(enroll.EnrollId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.Courses, "CourseId", "CourseId", enroll.CourseId); ViewData["StudentAuId"] = new SelectList(_context.Students, "StudentAuId", "FirstName", enroll.StudentAuId); return(View(enroll)); }
/// <summary> /// 保存转班记录 /// </summary> /// <param name="btn"></param> /// <returns></returns> public static bool SaveClass_transfe(Enroll en, ClassesTrans ct) { bool ret = false; DBRepository db = new DBRepository(DBKeys.PRX); try { db.BeginTransaction();//事务开始 Enroll en_old = db.GetById <Enroll>(en.ID); string oldclassid = en_old.ClassID;//原来的班级号 en_old.ClassID = en.ClassID; en_old.UpdateTime = en.UpdateTime; en_old.UpdatorId = en.UpdatorId; db.Update(en_old); //把报名表中的classid改成新的 string strsql = "delete from AttendanceRecord where AttendanceTypeID = 1 and StudentID = '" + en_old.StudentID + "' and ClassID = '" + oldclassid + "'"; db.Execute(strsql); //删除未考勤多余的学员课程记录 if (AddClassesTrans(ct, db) > 0) { db.Commit(); //事务提交 db.Dispose(); //资源释放 ClassListData.RefreshClassList(en.ClassID, en.UpdatorId); //刷新排课 ret = true; //新增成功 } } catch (Exception ex) { db.Rollback(); db.Dispose();//资源释放 throw new Exception(ex.Message + "。" + ex.InnerException.Message); } return(ret); }
//Status True public List <Enroll> GetAllEnrollsByRegNoTrue(String RegNo) { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT * FROM enrollcourse WHERE RegistrationNo='" + RegNo + "' and Status = '1' "; SqlCommand command = new SqlCommand(query, connection); List <Enroll> list = new List <Enroll>(); connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Enroll aEnroll = new Enroll(); aEnroll.StudentRegNo = reader["RegistrationNo"].ToString(); aEnroll.CourseId = Convert.ToInt32(reader["CorseId"].ToString()); aEnroll.Date = Convert.ToDateTime(reader["Date"].ToString()); aEnroll.Status = Convert.ToBoolean(reader["Status"].ToString()); list.Add(aEnroll); } reader.Close(); } connection.Close(); return(list); }
private bool IsStudentEnrollThisCourse(Enroll enrollObj) { bool check = gateway.IsStudentEnrollThisCourse(enrollObj); if (check) return true; return false; }
public List <Enroll> LoadCourseName() { string query = "Select * from Course"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); List <Enroll> students = new List <Enroll>(); try { SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Enroll student = new Enroll(); student.DepartmentId = Convert.ToInt32(reader["DepartmentID"].ToString()); student.CourseId = Convert.ToInt32(reader["CourseId"].ToString()); student.CourseName = reader["CourseName"].ToString(); students.Add(student); } reader.Close(); } catch (Exception e) { connection.Close(); throw e; } connection.Close(); return(students); }
public void DeleteEnroll(int id) { Enroll enroll = FindEnroll(id); moodleDAL.Enrolls.Remove(enroll); moodleDAL.SaveChanges(); }
public bool IsStudentEnrollThisCourse(Enroll enrollObj) { string query = "Select * from Enroll where StudentID=@studentId and CourseID=@courseId and isDeleted='False'"; SqlCommand checkCommand = new SqlCommand(query, connection); checkCommand.Parameters.Clear(); checkCommand.Parameters.Add("courseId", SqlDbType.Int); checkCommand.Parameters["courseId"].Value = enrollObj.CourseId; checkCommand.Parameters.Add("studentId", SqlDbType.Int); checkCommand.Parameters["studentId"].Value = enrollObj.StudentId; connection.Open(); try { SqlDataReader reader = checkCommand.ExecuteReader(); if (reader.Read()) { connection.Close(); reader.Close(); return(true); } reader.Close(); } catch (Exception e) { connection.Close(); throw e; } connection.Close(); return(false); }
public async Task ValidateAsync_should_succeed_when_command_valid() { var student = new Student(Guid.NewGuid(), "existing", "Student"); var studentsRepository = NSubstitute.Substitute.For <IStudentsRepository>(); studentsRepository.FindByIdAsync(Arg.Any <Guid>(), Arg.Any <CancellationToken>()) .ReturnsForAnyArgs(student); var course = new Course(Guid.NewGuid(), "existing course"); var coursesRepository = NSubstitute.Substitute.For <ICoursesRepository>(); coursesRepository.FindByIdAsync(Arg.Any <Guid>(), Arg.Any <CancellationToken>()) .ReturnsForAnyArgs(course); var unitOfWork = NSubstitute.Substitute.For <ISchoolUnitOfWork>(); unitOfWork.StudentsRepository.ReturnsForAnyArgs(studentsRepository); unitOfWork.CoursesRepository.ReturnsForAnyArgs(coursesRepository); var sut = new EnrollValidator(unitOfWork); var command = new Enroll(course.Id, student.Id); var result = await sut.ValidateAsync(command, CancellationToken.None); result.Should().NotBeNull(); result.Success.Should().BeTrue(); result.Errors.Should().BeEmpty(); }
public async Task <ActionResult> CreateEnrollment(Enroll enroll) { _context.Enrolls.Add(enroll); await _context.SaveChangesAsync(); return(Ok(enroll)); }
public bool IsStudentEnrollThisCourse(Enroll enrollObj) { string query = "Select * from Enroll where StudentID=@studentId and CourseID=@courseId and isDeleted='False'"; SqlCommand checkCommand = new SqlCommand(query, connection); checkCommand.Parameters.Clear(); checkCommand.Parameters.Add("courseId", SqlDbType.Int); checkCommand.Parameters["courseId"].Value = enrollObj.CourseId; checkCommand.Parameters.Add("studentId", SqlDbType.Int); checkCommand.Parameters["studentId"].Value = enrollObj.StudentId; connection.Open(); try { SqlDataReader reader = checkCommand.ExecuteReader(); if (reader.Read()) { connection.Close(); reader.Close(); return true; } reader.Close(); } catch (Exception e) { connection.Close(); throw e; } connection.Close(); return false; }
public string InsertEnrolment(Enroll enrollObj) { string query = "Insert into Enroll values(@courseId, @studentId,@enrollDate,@isDeleted)"; SqlCommand insertCommand = new SqlCommand(query, connection); insertCommand.Parameters.Clear(); insertCommand.Parameters.Add("courseId", SqlDbType.Int); insertCommand.Parameters["courseId"].Value = enrollObj.CourseId; insertCommand.Parameters.Add("studentId", SqlDbType.Int); insertCommand.Parameters["studentId"].Value = enrollObj.StudentId; insertCommand.Parameters.Add("enrollDate", SqlDbType.Date); insertCommand.Parameters["enrollDate"].Value = enrollObj.EnrollDate; insertCommand.Parameters.Add("isDeleted", SqlDbType.Bit); insertCommand.Parameters["isDeleted"].Value = 0; connection.Open(); try { int rowAffected = insertCommand.ExecuteNonQuery(); connection.Close(); if (rowAffected > 0) return "Saved Successfully"; return "Saved Failed"; } catch (Exception e) { throw e; } }
/// <summary> /// Enrolls a student in a class. /// </summary> /// <param name="subject">The department subject abbreviation</param> /// <param name="num">The course number</param> /// <param name="season">The season part of the semester</param> /// <param name="year">The year part of the semester</param> /// <param name="uid">The uid of the student</param> /// <returns>A JSON object containing {success = {true/false}, /// false if the student is already enrolled in the Class.</returns> public IActionResult Enroll(string subject, int num, string season, int year, string uid) { try { var query = ( from cls in db.Class join crs in db.Course on cls.CourseId equals crs.CourseId where crs.Abrv == subject where crs.CNumber == num where cls.SemesterSeason == season where cls.SemesterYear == year select new { classId = cls.ClassId }).FirstOrDefault(); Enroll enrollment = new Enroll() { Grade = "--", UId = uid, ClassId = query.classId }; db.Add(enrollment); db.SaveChanges(); return(Json(new { success = true })); } catch { return(Json(new { success = false })); } }
// Enroll successfull code here public string EnrollCourse(Enroll enrull) { if (enrollGateway.allreadyEnrolled(enrull)) { int rowAffect = enrollGateway.UpdateEnrolledCourse(enrull); if (rowAffect > 0) { return("Enrolled Course Updated Successful"); } else { return("Operation Failed"); } } else { int rowAffact = enrollGateway.EnrollCourse(enrull); if (rowAffact > 0) { return("Course Enrolledment Successful"); } else { return("Operation Failed"); } } }
public Enroll Create(Enroll itemToCreate) { var enroll = _context.Enrolls.Add(itemToCreate); _context.SaveChanges(); return(enroll); }
public async Task <IActionResult> PutEnroll([FromRoute] int id, [FromBody] Enroll enroll) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != enroll.ID) { return(BadRequest()); } _context.Entry(enroll).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnrollExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task SetPayStatus(Enroll enroll, Member member, EnrollStatus enrollStatus, string strPayType) { if (enroll.Status == enrollStatus) { return; } enroll.Status = enrollStatus; enroll.PaidTime = DateTime.Now; bool bIsPaid = enrollStatus == EnrollStatus.PaySuccess; if (bIsPaid)//支付成功 { enroll.PayType = strPayType; enroll.Note = "已完成支付"; } else { enroll.PayType = ""; enroll.Note = "已完成撤销支付"; } PayRecordHelper helper = new PayRecordHelper(); await helper.SaveAsycn(enroll, bIsPaid); await ScoreRule(enroll, member, bIsPaid, true); await SaveChangesAsync(); }
public ActionResult SaveResult(Enroll enroll) { ViewBag.StudentRegNo = AStudentResultManager.GetStudentRegNoForDropdown(); ViewBag.allGradelist = AStudentResultManager.GetAllGradeForDropdown(); ViewBag.Message = AStudentResultManager.SaveStudentResult(enroll); return(View()); }
public BaseResponseDto Update(EnrollUpdateModel enrollUpdateModel) { BaseResponseDto responseDto = null; if (enrollUpdateModel == null) { responseDto = new BaseResponseDto { Status = 1, Message = "Faulthy enroll info" }; return(responseDto); } Enroll existingEnroll = null; try { existingEnroll = _uow.GetRepository <Enroll>() .GetAll() .FirstOrDefault(e => e.EnrollId == enrollUpdateModel.EnrollId); } catch (Exception e) { throw e; } if (existingEnroll == null) { responseDto = new BaseResponseDto { Status = 2, Message = "Not enrolled to sharing yet" }; return(responseDto); } existingEnroll.SharingId = enrollUpdateModel.SharingId; existingEnroll.SubscriptionId = enrollUpdateModel.SubscriptionId; existingEnroll.IsDisable = enrollUpdateModel.IsDisable; try { _uow.GetRepository <Enroll>().Update(existingEnroll); _uow.Commit(); } catch (Exception e) { throw e; } responseDto = new BaseResponseDto { Status = 0, Message = "Success" }; return(responseDto); }
public IHttpActionResult Post(Enroll enroll) { enRepo.Insert(enroll); string url = Url.Link("GetByUserId", new { id = enroll.E_Id }); return(Created(url, enroll)); }
public bool IsPaid(Enroll enroll) { if (enroll == null) { return(false); } return(enroll.Status == EnrollStatus.PaySuccess); }
public string Save(Enroll enrollObj) { bool check = IsStudentEnrollThisCourse(enrollObj); if (!check) { string message = gateway.InsertEnrolment(enrollObj); return message; } return "This Student Already Enroll this Course"; }
public List<Enroll> LoadAllRegNo() { string query = "Select StudentID, RegNo, DepartmentID from Student"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); List<Enroll> students = new List<Enroll>(); try { SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Enroll student = new Enroll(); student.StudentId = Convert.ToInt32(reader["StudentID"].ToString()); student.RegNo = reader["RegNo"].ToString(); student.DepartmentId = Convert.ToInt32(reader["DepartmentID"].ToString()); students.Add(student); } reader.Close(); } catch (Exception e) { connection.Close(); throw e; } connection.Close(); return students; }
public ActionResult Index(Enroll enrollObj) { ViewBag.getRegNo = manage.StudentRegList(); ViewBag.insert = manage.Save(enrollObj); return View(); }
private void SaveData(IEnumerable<Student> listStudents, IEnumerable<Parent> listParents, AcademicYear academicYear, List<string> emails) { var allEnrolls = _enrollRepository.GetAllsEnrolls(); var enrls = allEnrolls.Where(x => x.AcademicYear.Id == academicYear.Id); if (enrls.Any()) throw new Exception("Ya hay alumos en este grado, borrelos e ingreselos denuevo"); var allParents = _parentRepository.GetAllParents(); var allStudents = _studentRepository.GetAllStudents(); if (!(((EnrollRepository)_enrollRepository).GeContext().Equals(((ParentRepository)_parentRepository).GeContext()))) return; if (!(((EnrollRepository)_enrollRepository).GeContext().Equals(((StudentRepository)_studentRepository).GeContext()))) return; if (!(((EnrollRepository)_enrollRepository).GeContext().Equals(((AcademicYearRepository)_academicYearRepository).GeContext()))) return; int iterator = 0; foreach (var pare in listParents) { var temp = allParents.Where(x => x.IdNumber == pare.IdNumber); if (!temp.Any()) { var newUser = new User { DisplayName = pare.FirstName, Email = emails[iterator], Password = _passwordGenerationService.GenerateTemporaryPassword(), IsActive = true, Role = Roles.Padre }; //TODO: add to newUsers table. newUser = _userRepository.Create(newUser); pare.MyUser = newUser; _parentRepository.Create(pare); } else { pare.Id = temp.First().Id; } iterator++; } foreach (var stu in listStudents) { var temp = allStudents.Where(x => x.IdNumber == stu.IdNumber); if (!temp.Any()) { stu.MyUser = stu.Tutor1.MyUser; _studentRepository.Create(stu); } else stu.Id = temp.First().Id; var enr = allEnrolls.Where(x => x.AcademicYear.Id == academicYear.Id && x.Student.Id == stu.Id); if (enr.Any()) continue; var te = new Enroll(); var academicYearTemp = _academicYearRepository.GetById(academicYear.Id); var studentTemp = _studentRepository.GetById(stu.Id); te.AcademicYear = academicYearTemp; te.Student = studentTemp; _enrollRepository.Create(te); } }
public Enroll Update(Enroll itemToUpdate) { var enroll = GetById(itemToUpdate.Id); bool academicYear = false; bool student = false; if (enroll.AcademicYear != itemToUpdate.AcademicYear) { enroll.AcademicYear = itemToUpdate.AcademicYear; academicYear = true; } if (enroll.Student != itemToUpdate.Student) { enroll.Student = itemToUpdate.Student; student = true; } return Update(enroll, academicYear, student); }
public Enroll Create(Enroll itemToCreate) { var enroll = _context.Enrolls.Add(itemToCreate); _context.SaveChanges(); return enroll; }
public void Detach(Enroll enroll) { _context.Entry(enroll).State = EntityState.Detached; }
public Enroll Update(Enroll itemToUpdate, bool academicYear, bool student) { if (academicYear) { _context.Entry(itemToUpdate.AcademicYear).State = EntityState.Modified; } if (student) { _context.Entry(itemToUpdate.Student).State = EntityState.Modified; } _context.SaveChanges(); return itemToUpdate; }