public async Task <string> teachingDidLoad([FromBody] Teaching teaching) { Console.WriteLine("TeachingDidLoad: " + teaching.ToString()); var result = await produce("TeachingDidLoad", teaching.ToString()); return(result); }
public static void addLecturer(IEnumerable <string> selected_modules, string fname, string lname, string email, string password) { using (xinyuedbEntities db = new xinyuedbEntities()) { User user = new User { email = email, accountType = "lecturer", password = PasswordHash.HashPassword(password) }; db.Users.Add(user); Lecturer lecturer = new Lecturer { fName = fname, lName = lname, userId = user.userId, }; db.Lecturers.Add(lecturer); foreach (var module in selected_modules) { Teaching teaching = new Teaching { lecturerId = lecturer.lecturerId, moduleId = Int32.Parse(module) }; db.Teachings.Add(teaching); } db.SaveChanges(); } }
public async Task <IHttpActionResult> PostTeaching(Teaching teaching) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Teachings.Add(teaching); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (TeachingExists(teaching.AccountId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = teaching.AccountId }, teaching)); }
public IHttpActionResult CreateNewTeachings(Teaching newTeaching) { //var std = _context.Students.Single(c => c.studentID == newTeaching.student.studentID); var std = _context.Students.SingleOrDefault(c => c.studentName == newTeaching.student.studentName); if (std == null) { return(NotFound()); } // var crs = _context.Courses.Single(c => c.courseID == newTeaching.course.courseID); var crs = _context.Courses.SingleOrDefault(c => c.courseName == newTeaching.course.courseName); if (crs == null) { return(NotFound()); } var sDate = newTeaching.startingDate; var teaching = new Teaching { student = std, course = crs, startingDate = sDate }; _context.Teachings.Add(teaching); _context.SaveChanges(); return(Ok()); }
private Stats parseJSONStats(JSONNode stats) { Teaching t = new Teaching(stats["teaching"][0].AsInt, stats["teaching"][1].AsInt,stats["teaching"][2].AsInt,stats["teaching"][3].AsInt,stats["teaching"][4].AsInt); Combat c = new Combat(stats["combat"][0].AsInt,stats["combat"][1].AsInt,stats["combat"][2].AsInt,stats["combat"][3].AsInt,stats["combat"][4].AsInt); Intelligence i = new Intelligence(stats["intelligence"][0].AsInt,stats["intelligence"][1].AsInt,stats["intelligence"][2].AsInt,stats["intelligence"][3].AsInt,stats["intelligence"][4].AsInt); return new Stats(t, c, i); }
/// <summary> /// Get program for course, teacher and classroom /// </summary> /// <param name="courseId"></param> /// <param name="teacherId"></param> /// <param name="classRoomId"></param> /// <returns></returns> public Program GetProgram(int courseId, int teacherId, int classRoomId) { logger.Info("Get program for course {@courseId}, teacher {@teacherId} and classroom {@classRoomId}", courseId, teacherId, classRoomId); Teaching teaching = teachingsService.Value.GetTeaching(courseId, teacherId); ClassRoom classRoom = classRoomsService.Value.GetClassRoom(classRoomId); var program = db.ProgramsRepository.Get(p => p.ClassRoomId == classRoomId && p.Teaching.CourseId == courseId && p.Teaching.TeacherId == teacherId) .FirstOrDefault(); if (program == null) { logger.Info("Program not found for course {@courseId}, teacher {@teacherId} and classroom {@classRoomId}", courseId, teacherId, classRoomId); var ex = new ProgramNotFoundException(string.Format("Program not found for course {0}, teacher {1} and classroom {2}", courseId, teacherId, classRoomId)); ex.Data.Add("teacherId", teacherId); ex.Data.Add("courseId", courseId); ex.Data.Add("classRoomId", classRoomId); throw ex; } return(program); }
public async Task <IHttpActionResult> PutTeaching(string id, Teaching teaching) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != teaching.AccountId) { return(BadRequest()); } db.Entry(teaching).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeachingExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
static void Main(string[] args) { Console.WriteLine("-- TEACHING MATRIX -- " + DateTime.Now.ToLongTimeString() + " -"); var teacher = new Teaching(100, 50, 1); teacher.Progress = DrawProgress; //умножение на 2 - работает до 7 var inpValues = new byte[] { 1, 2, 3, 4, 5, 6 }; var outValues = new byte[] { 2, 4, 6, 8, 10, 12 }; var res = teacher.Teach(inpValues, outValues, 1000); Console.CursorTop += teacher.resList.Count > 0 ? teacher.resList[0].yHeight * 2 + 3 : 3; if (res == TeachingResult.TeachingComplete) { Console.WriteLine("Завершено. Всего матриц " + teacher.resList.Count); MatrixDraw.DrawMatrix(teacher.resList[0]); } else if (res == TeachingResult.MaxRowLimitReached) { Console.WriteLine("Превышен максимальный размер матрицы."); Console.ReadKey(); return; } else if (res == TeachingResult.ContinueTeaching) { Console.WriteLine("Незавершено. Всего матриц: " + teacher.resList.Count); if (teacher.resList.Count == 0) { Console.ReadKey(); return; } } Console.WriteLine(); foreach (var m in teacher.resList) { Console.WriteLine("Тест на обучающей выборке"); CheckFoundMatrix(m, inpValues, outValues); } while (true) { Console.WriteLine("Проверить значение: "); var read = Console.ReadLine(); if (String.IsNullOrWhiteSpace(read)) { break; } byte intTemp = Convert.ToByte(read); var matr = new iMatrixSpc.iMatrixByte(teacher.resList[0]); var mRes = matr.Process(intTemp); Console.WriteLine(intTemp + " => " + mRes); } }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Teaching teaching = await db.Teachings.FindAsync(id); if (teaching == null) { return(HttpNotFound()); } string user = User.Identity.GetUserId(); int?dept = (from u in db.Users where u.Id == user select u.DepartmentId).FirstOrDefault(); List <int> depts = new List <int>(from d in db.Departments where d.DepartmentId == dept || d.DepartmentParentId == dept select d.DepartmentId); List <Subject> subjects = new List <Subject>(from s in db.Subjects where depts.Contains(s.RelatedDepartment.DepartmentId) select s); List <ApplicationUser> users = new List <ApplicationUser> (from u in db.Users where depts.Contains(u.RelatedDepartment.DepartmentId) && u.Role == "Examiner" select u); ViewBag.SubjectId = new SelectList(subjects, "SubjectId", "SubjectName", teaching.SubjectId); ViewBag.ExaminerId = new SelectList(users, "Id", "FirstName", teaching.ExaminerId); return(View(teaching)); }
/// <summary> /// Get teaching by Id and return a teachingDto /// </summary> /// <param name="teachingId"></param> /// <returns></returns> public TeachingDto GetTeachingDtoById(int teachingId) { logger.Info("Get teaching dto by Id {@teachingId}", teachingId); Teaching teaching = GetTeachingById(teachingId); return(Converters.TeachingsConverter.TeachingToTeachingDto(teaching)); }
public static void editLecturer(int lecturerId, IEnumerable <string> selected_modules, string fname, string lname, string email) { using (xinyuedbEntities db = new xinyuedbEntities()) { var lecturer = db.Lecturers.Where(l => l.lecturerId == lecturerId).FirstOrDefault(); lecturer.User.email = email; lecturer.fName = fname; lecturer.lName = lname; var modules = db.Teachings.Where(t => t.lecturerId == lecturerId); db.Teachings.RemoveRange(modules); foreach (var module in selected_modules) { Teaching teaching = new Teaching { lecturerId = lecturer.lecturerId, moduleId = Int32.Parse(module) }; db.Teachings.Add(teaching); } db.SaveChanges(); } }
public async Task <ActionResult> Edit([Bind(Include = "TeachingId,ExaminerId,SubjectId")] Teaching teaching) { if (ModelState.IsValid) { db.Entry(teaching).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } string user = User.Identity.GetUserId(); int?dept = (from u in db.Users where u.Id == user select u.DepartmentId).FirstOrDefault(); List <int> depts = new List <int>(from d in db.Departments where d.DepartmentId == dept || d.DepartmentParentId == dept select d.DepartmentId); List <Subject> subjects = new List <Subject>(from s in db.Subjects where depts.Contains(s.RelatedDepartment.DepartmentId) select s); List <ApplicationUser> users = new List <ApplicationUser> (from u in db.Users where depts.Contains(u.RelatedDepartment.DepartmentId) && u.Role == "Examiner" select u); ViewBag.SubjectId = new SelectList(subjects, "SubjectId", "SubjectName", teaching.SubjectId); ViewBag.ExaminerId = new SelectList(users, "Id", "FirstName", teaching.ExaminerId); return(View(teaching)); }
public ActionResult TeachersDeleteConfirmed(Guid id) { Teaching teaching = dbTeachings.Teachings.Find(id); dbTeachings.Teachings.Remove(teaching); dbTeachings.SaveChanges(); return(RedirectToAction("TeachersIndex", routeValues: new { subjectId = teaching.SubjectID })); }
/// <summary> /// Remove teacher from course /// NOTE better use DELETE to courses/{courseId}/teachers/{teachersId} /// it is more RESTful /// NOTE this is the old method /// </summary> /// <param name="courseId"></param> /// <param name="teacherId"></param> /// <returns></returns> public Teaching RemoveTeacherFromCourse(int courseId, int teacherId) { // 4 errors: // 1) courseId not found // 2) teacherId not found // 3) teaching not found // 4) cannot remove association because it is in use Course course = db.CoursesRepository.GetByID(courseId); if (course == null) { logger.Error("Course {@courseId} not found", courseId); var ex = new CourseNotFoundException(String.Format("Course {0} not found", courseId)); ex.Data.Add("courseId", courseId); throw ex; } TeacherUser teacher = db.TeachersRepository.Get(t => t.Id == teacherId).FirstOrDefault(); if (teacher == null) { logger.Error("Teacher {@teacherId} not found", teacherId); var ex = new TeacherNotFoundException(String.Format("Teacher {0} not found", courseId)); ex.Data.Add("teacherId", teacherId); throw ex; } // Maybe we don't need to check Course and Teacher at all? Teaching teaching = db.TeachingAssignmentsRepository.Get(ta => ta.CourseId == courseId && ta.TeacherId == teacherId).FirstOrDefault(); if (teaching == null) { logger.Error("Teaching assignment for teacher {@teacherId} and course {@courseId} not found", teacherId, courseId); var ex = new TeachingNotFoundException(String.Format("Teaching assignment for teacher {0} and course {1} not found", teacherId, courseId)); ex.Data.Add("teacherId", teacherId); ex.Data.Add("courseId", courseId); throw ex; } try { // Probably another method in service? db.TeachingAssignmentsRepository.Delete(teaching); db.Save(); } catch (Exception ex) { logger.Error(ex, "Removal of teaching assignment failed for teacher {@teacherId} and course {@courseId}", teacherId, courseId); throw; } return(null); }
/// <summary> /// Delete teaching /// </summary> /// <param name="courseId"></param> /// <param name="teacherId"></param> /// <returns></returns> public Teaching DeleteTeaching(int courseId, int teacherId) { Teaching teaching = GetTeaching(courseId, teacherId); db.TeachingAssignmentsRepository.Delete(teaching); db.Save(); return(teaching); }
private static TeacherReportDto.CourseDto TeachingToTeacherReportCourse(Teaching teaching) { return(new TeacherReportDto.CourseDto() { CourseId = teaching.Course.Id, CourseName = teaching.Course.Name, ClassRooms = teaching.Programs.Select(p => ProgramToTeacherReportCourseClassRoom(p)) }); }
public ActionResult Edit(int id) { Teaching teaching = db.Teachings.Find(id); if (teaching == null) { return(RedirectToAction("Index")); } return(View(teaching)); }
public async Task <IActionResult> UpdateTeaching([FromBody] Teaching teachings) { using (var context = new UniversityDbContext()) { context.Teachings.Update(teachings); await context.SaveChangesAsync(); return(Ok()); } }
public ActionResult Edit(int id = 0) { Teaching teaching = db.Teachings.Find(id); if (teaching == null) { return(HttpNotFound()); } return(View(teaching)); }
public ActionResult DeleteConfirmed(int id) { Teaching teaching = db.Teachings.Find(id); var filePath = Path.Combine(Server.MapPath("~/UploadedFiles/"), teaching.Filename); System.IO.File.Delete(filePath); db.Teachings.Remove(teaching); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Teaching to teachingDto /// </summary> /// <param name="teaching"></param> /// <returns></returns> public static TeachingDto TeachingToTeachingDto(Teaching teaching) { return(new TeachingDto() { TeachingId = teaching.Id, CourseId = teaching.CourseId, TeacherId = teaching.TeacherId, CourseName = teaching.Course.Name, TeacherName = teaching.Teacher.UserName }); }
public ActionResult Edit(Teaching teaching) { if (ModelState.IsValid) { db.Entry(teaching).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(teaching)); }
public async Task <IHttpActionResult> GetTeaching(string id) { Teaching teaching = await db.Teachings.FindAsync(id); if (teaching == null) { return(NotFound()); } return(Ok(teaching)); }
public void AddTeaching(int lecturerId, int courseId) { Lecturer lecturer = _ctx.Lecturers.Find(lecturerId); Course course = _ctx.Courses.Find(courseId); var newEnrol = new Teaching { LecturerId = lecturerId, CourseId = courseId }; _ctx.Teachings.Add(newEnrol); Save(); }
public Stats(Teaching teaching, Combat combat, Intelligence intelligence){ this.teaching = teaching; this.combat = combat; this.intelligence = intelligence; }