public bool NewCourse(string Name, int IsElective, int Credit) { try { using (var context = new course_selectionContext()) { var data = new CourseDb(); int newid = context.CourseDb.ToList().Count() == 0 ? 1 : context.CourseDb.ToList().Max(x => x.Code) + 1; data.Code = newid; data.Name = Name; data.IsElective = IsElective; data.Credit = Credit; context.CourseDb.Add(data); context.SaveChanges(); Console.WriteLine("新课程的课程编号为:" + newid); } } catch (Exception e) { Console.WriteLine(e.Message); return(false); } return(true); }
/// <summary> /// Remove course in repository. /// </summary> /// <param name="course"></param> /// <returns></returns> public async Task RemoveAsync(CourseDb course) { if (course == null) { throw new ArgumentNullException("course"); } _videoDbContext.Courses.Remove(course); await _videoDbContext.SaveChangesAsync().ConfigureAwait(false); }
/// <summary> /// Update course in repository. /// </summary> /// <param name="course"></param> /// <returns></returns> public void Update(CourseDb course) { if (course == null) { throw new ArgumentNullException("course"); } _videoDbContext.Entry(course).State = EntityState.Modified; _videoDbContext.SaveChanges(); }
/// <summary> /// Update course in repository. /// </summary> /// <param name="course"></param> /// <returns></returns> public async Task <CourseDb> UpdateAsync(CourseDb course) { if (course == null) { throw new ArgumentNullException("course"); } _videoDbContext.Entry(course).State = EntityState.Modified; await _videoDbContext.SaveChangesAsync().ConfigureAwait(false); return(await Task.FromResult(course)); }
private CourseDb ConvertToCourseDb(CourseDetail courseDetail) { CourseDb course = new CourseDb() { Name = courseDetail.Name, PrerequisiteKnowledge = courseDetail.PrerequisiteKnowledge, CommenceDate = courseDetail.CommenceDate, StartAppliedDate = courseDetail.StartAppliedDate, CompleteDate = courseDetail.CompleteDate, Tuition = courseDetail.Tuition, Published = false }; return(course); }
private CourseDetail ConvertToCourseDetail(CourseDb courseDb) { CourseDetail course = new CourseDetail() { Name = courseDb.Name, PrerequisiteKnowledge = courseDb.PrerequisiteKnowledge, CommenceDate = courseDb.CommenceDate, StartAppliedDate = courseDb.StartAppliedDate, CompleteDate = courseDb.CompleteDate, Tuition = courseDb.Tuition, Published = courseDb.Published, NumberOfStudent = courseDb.CourseStudents.Count() }; return(course); }
public async Task CreateCourse(CourseDb course) { CourseStudentDb courseStudent = new CourseStudentDb() { Course = course, }; _context.Add(course); try { await _context.SaveChangesAsync(); } catch (Exception ex) { throw new DBOperationException(ex); } }
public async Task <Result <CourseDb> > DeleteAsync(CourseDb course) { try { context.Courses.Remove(course); await context.SaveChangesAsync().ConfigureAwait(false); return(Result <CourseDb> .Ok(course)); } catch (DbUpdateConcurrencyException e) { return(Result <CourseDb> .Fail <CourseDb>($"Course not deleted. {e.Message}")); } catch (DbEntityValidationException e) { return(Result <CourseDb> .Fail <CourseDb>($"Invalid profile. {e.Message}")); } }
public async Task <Result <CourseDb> > UpdateAsync(CourseDb course) { try { context.Entry(course).State = EntityState.Modified; await context.SaveChangesAsync().ConfigureAwait(false); return(Result <CourseDb> .Ok(course)); } catch (DbUpdateConcurrencyException e) { return((Result <CourseDb>) Result <CourseDb> .Fail <CourseDb>($"Cannot save course. {e.Message}")); } catch (DbEntityValidationException e) { return((Result <CourseDb>) Result <CourseDb> .Fail <CourseDb>($"Invalid course. {e.Message}")); } }
public static void CreateCourse() { Console.Clear(); Console.Write("Title: "); string title = Console.ReadLine(); Console.Write("Stream: 1) Java 2) C#: "); bool result = Int32.TryParse(Console.ReadLine(), out int x); while (!result || (x != 1 && x != 2)) { Console.Write("Wrong input! Please select using number 1 or 2\nStream: 1) Java 2) C#: "); result = Int32.TryParse(Console.ReadLine(), out x); } Stream streamID = (Stream)x; Console.Write("Type: 1) Part Time 2) Full Time: "); result = Int32.TryParse(Console.ReadLine(), out x); while (!result || (x != 1 && x != 2)) { Console.Write("Wrong input! Please select using number 1 or 2\nType: 1) Part Time 2) Full Time: "); result = Int32.TryParse(Console.ReadLine(), out x); } Type typeID = (Type)x; Console.Write("Starting Date: "); result = DateTime.TryParse(Console.ReadLine(), out DateTime startDate); while (!result || startDate < DateTime.Now) { Console.Write("Wrong input!\nStarting date has to be set as YYYY/MM/DD and cant be a past date\nStarting Date: "); result = DateTime.TryParse(Console.ReadLine(), out startDate); } Console.Write("Ending Date: "); result = DateTime.TryParse(Console.ReadLine(), out DateTime endDate); while (!result || endDate < startDate) { Console.Write("Wrong input!\nEnding date has to be set as YYYY/MM/DD and cant be earlier date than Starting date\nEnding Date: "); result = DateTime.TryParse(Console.ReadLine(), out endDate); } CourseDb.CreateCourse(title, streamID, typeID, startDate, endDate); Console.WriteLine("Course creation successful!\n"); Console.Clear(); }
public static void AddAssignmentInCourse() { Console.Clear(); AssignmentDb aDB = new AssignmentDb(); CourseDb cDB = new CourseDb(); List <Course> courses = cDB.GetCourses(); List <Assignment> assignments = aDB.GetAssignments(); if (courses.Count != 0 && assignments.Count != 0) { Console.WriteLine("Select an assignment to add by using its number on the list: \n"); ShowLists.ShowList(assignments, "Students"); bool result = Int32.TryParse(Console.ReadLine(), out int assignmentID); while (!result || (assignmentID < 1 || assignmentID > assignments.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {assignments.Count} "); result = Int32.TryParse(Console.ReadLine(), out assignmentID); } Console.Clear(); Console.WriteLine("Select a course by using its number on the list: \n"); ShowLists.ShowList(courses, "Courses"); result = Int32.TryParse(Console.ReadLine(), out int courseID); while (!result || (courseID < 1 || courseID > courses.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {courses.Count} "); result = Int32.TryParse(Console.ReadLine(), out courseID); } Console.Clear(); AssignmentsPerCourseDb.AddAssignmentToCourse(assignmentID, courseID); Console.WriteLine("Assignment added successfully to Course!"); } else { Console.WriteLine("There aren't neither Students nor Courses yet"); } }
public async Task EditCourse() { HiddenEditButton = false; HiddenSaveButton = true; EditCourseBool = true; Course c = new Course(); c.Id = Course.Id; c.CourseName = Course.CourseName; c.Points = Course.Points; c.Description = Course.Description; c.StartDate = Course.StartDate; c.EndDate = Course.EndDate; c.CourseAdmin = Course.CourseAdmin; await CourseDb.Update(c); StateHasChanged(); }
public static void AddStudentInCourse() { Console.Clear(); StudentDb sDB = new StudentDb(); CourseDb cDB = new CourseDb(); List <Course> courses = cDB.GetCourses(); List <Student> students = sDB.GetStudents(); if (courses.Count != 0 && students.Count != 0) { Console.WriteLine("Select a student to add by using its number on the list: \n"); ShowLists.ShowList(students, "Students"); bool result = Int32.TryParse(Console.ReadLine(), out int studentID); while (!result || (studentID < 1 || studentID > students.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {students.Count} "); result = Int32.TryParse(Console.ReadLine(), out studentID); } Console.Clear(); Console.WriteLine("Select a course by using its number on the list: \n"); ShowLists.ShowList(courses, "Courses"); result = Int32.TryParse(Console.ReadLine(), out int courseID); while (!result || (courseID < 1 || courseID > courses.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {courses.Count} "); result = Int32.TryParse(Console.ReadLine(), out courseID); } Console.Clear(); StudentsPerCourseDb.AddStudentToCourse(studentID, courseID); Console.WriteLine("Student enrolled to course successfully!"); } else { Console.WriteLine("There aren no Students or Courses yet"); } }
public static void AddTrainerInCourse() { Console.Clear(); TrainerDb tDB = new TrainerDb(); CourseDb cDB = new CourseDb(); List <Course> courses = cDB.GetCourses(); List <Trainer> trainers = tDB.GetTrainers(); if (courses.Count != 0 && trainers.Count != 0) { Console.WriteLine("Select a trainer to add by using its number on the list: \n"); ShowLists.ShowList(trainers, "Trainers"); bool result = Int32.TryParse(Console.ReadLine(), out int trainerID); while (!result || (trainerID < 1 || trainerID > trainers.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {trainers.Count} "); result = Int32.TryParse(Console.ReadLine(), out trainerID); } Console.Clear(); Console.WriteLine("Select a course by using its number on the list: \n"); ShowLists.ShowList(courses, "Courses"); result = Int32.TryParse(Console.ReadLine(), out int courseID); while (!result || (courseID < 1 || courseID > courses.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {courses.Count} "); result = Int32.TryParse(Console.ReadLine(), out courseID); } Console.Clear(); TrainersPerCourseDb.AddTrainerToCourse(trainerID, courseID); Console.WriteLine("Trainer added to course successfully!"); } else { Console.WriteLine("There aren no Trainers or Courses yet"); } }
public async Task <Result <CourseDb> > AddAsync(CourseDb course) { try { context.Courses.Add(course); await context.SaveChangesAsync().ConfigureAwait(false); return(Result <CourseDb> .Ok(course)); } catch (DbUpdateConcurrencyException e) { return((Result <CourseDb>) Result <CourseDb> .Fail <CourseDb>($"Cannot save course. {e.Message}")); } catch (DbUpdateException e) { return((Result <CourseDb>) Result <CourseDb> .Fail <CourseDb>($"Cannot save course. Duplicate field. {e.Message}")); } catch (DbEntityValidationException e) { return((Result <CourseDb>) Result <CourseDb> .Fail <CourseDb>($"Invalid course. {e.Message}")); } }
public List <Trainer> GetTrainersPerCourse(int courseID) { CourseDb cDB = new CourseDb(); List <Course> courses = cDB.GetCourses(); List <Trainer> trainersPerCourse = new List <Trainer>(); using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("select t.FirstName, t.LastName, t.Subject from Courses as c join TrainersPerCourse as tpc on c.CourseID = tpc.CourseID join Trainers as t on tpc.TrainerID = t.TrainerID where c.CourseID = @CourseID", conn)) { cmd.Parameters.Add(new SqlParameter("CourseID", courseID)); cmd.ExecuteNonQuery(); using (SqlDataReader rdr = cmd.ExecuteReader()) { if (rdr != null) { Console.WriteLine($" |{courses[courseID - 1].Title}|"); while (rdr.Read()) { trainersPerCourse.Add(new Trainer() { Id = trainersPerCourse.Count + 1, FirstName = (string)rdr["FirstName"], LastName = (string)rdr["LastName"], Subject = (string)rdr["Subject"] }); } } else { Console.WriteLine("There are no courses or trainers yet"); } } } } return(trainersPerCourse); }
public List <StudentPerCourse> GetStudentsPerCourse(int courseID) { CourseDb cDB = new CourseDb(); List <Course> courses = cDB.GetCourses(); List <StudentPerCourse> studentsPerCourse = new List <StudentPerCourse>(); using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("select c.Title, s.FirstName, s.LastName from Courses as c join StudentsPerCourse as spc on c.CourseID = spc.CourseID join Students as s on spc.StudentID = s.StudentID where c.CourseID = @CourseID", conn)) { cmd.Parameters.Add(new SqlParameter("CourseID", courseID)); cmd.ExecuteNonQuery(); using (SqlDataReader rdr = cmd.ExecuteReader()) { if (rdr != null) { Console.WriteLine($" |{courses[courseID-1].Title}|"); while (rdr.Read()) { studentsPerCourse.Add(new StudentPerCourse() { Id = studentsPerCourse.Count + 1, Title = (string)rdr["Title"], FirstName = (string)rdr["FirstName"], LastName = (string)rdr["LastName"] }); } } else { Console.WriteLine("There are no courses or students yet"); } } } } return(studentsPerCourse); }
public List <AssignmentPerCourse> GetAssignmentsPerCourse(int courseID) { CourseDb cDB = new CourseDb(); List <Course> courses = cDB.GetCourses(); List <AssignmentPerCourse> assignmentsPerCourse = new List <AssignmentPerCourse>(); using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("select a.Title from Courses as c join Assignments as a on c.CourseID = a.CourseID where c.CourseID = @CourseID", conn)) { cmd.Parameters.Add(new SqlParameter("CourseID", courseID)); cmd.ExecuteNonQuery(); using (SqlDataReader rdr = cmd.ExecuteReader()) { if (rdr != null) { Console.WriteLine($" |{courses[courseID - 1].Title}|"); while (rdr.Read()) { assignmentsPerCourse.Add(new AssignmentPerCourse() { Id = assignmentsPerCourse.Count + 1, Title = (string)rdr["Title"], }); } } else { Console.WriteLine("There are no courses or assignments yet"); } } } } return(assignmentsPerCourse); }
public void InitMock() { _tagDb = new TagDb() { TagId = "tag1", Content = "C#" }; _tagDbFirst = new List <TagDb>() { _tagDb, new TagDb() { TagId = "tag2", Content = "ASP" }, }; _tagDbSecond = new List <TagDb>() { new TagDb() { TagId = "tag3", Content = "Java" }, new TagDb() { TagId = "tag4", Content = "Javascript" }, }; _tagInfo = new TagInfo() { TagId = "tag1", Content = "C#" }; _tagInfoFirst = new List <TagInfo>() { _tagInfo, new TagInfo() { TagId = "tag2", Content = "ASP" }, }; _tagInfoSecond = new List <TagInfo>() { new TagInfo() { TagId = "tag3", Content = "Java" }, new TagInfo() { TagId = "tag4", Content = "Javascript" }, }; _coursesDb = new List <CourseDb>() { new CourseDb() { CourseId = "idCourse1", Name = "Course1", Price = 10, Date = DateTime.Now, Description = "Description1", Level = 1, Raiting = 5, RateCount = 3, Tags = _tagDbFirst }, new CourseDb() { CourseId = "idCourse2", Name = "Course2", Price = 20, Date = DateTime.Now, Description = "Description2", Level = 2, Raiting = 4, RateCount = 10, Tags = _tagDbSecond }, new CourseDb() { CourseId = "idCourse3", Name = "Course3", Price = 30, Date = DateTime.Now, Description = "Description3", Level = 2, Raiting = 3, RateCount = 15, Tags = _tagDbSecond }, new CourseDb() { CourseId = "idCourse4", Name = "Course4", Price = 40, Date = DateTime.Now, Description = "Description4", Level = 1, Raiting = 2, RateCount = 12, Tags = _tagDbFirst }, new CourseDb() { CourseId = "idCourse5", Name = "Course5", Price = 50, Date = DateTime.Now, Description = "Description5", Level = 2, Raiting = 3, RateCount = 24, Tags = _tagDbFirst }, }.AsQueryable(); _coursesInfo = new List <CourseInfo>() { new CourseInfo() { Name = "Course1", Price = 10, Description = "Description1", Duration = 15, Level = 1, Raiting = 5 }, new CourseInfo() { Name = "Course2", Price = 20, Description = "Description2", Duration = 25, Level = 2, Raiting = 4 }, new CourseInfo() { Name = "Course3", Price = 30, Description = "Description3", Duration = 35, Level = 2, Raiting = 3 }, new CourseInfo() { Name = "Course4", Price = 40, Description = "Description4", Duration = 45, Level = 1, Raiting = 2 }, new CourseInfo() { Name = "Course5", Price = 50, Description = "Description5", Duration = 55, Level = 2, Raiting = 3 } }.AsQueryable(); _oneCourseDb = new CourseDb() { CourseId = "idCourseFirst", Name = "CourseFirst", Price = 40, Date = DateTime.Now, Description = "DescriptionFirst", Level = 1, Raiting = 5 }; _oneCourseInfo = new CourseInfo() { Name = "CourseFirst", Price = 40, Description = "DescriptionFirst", Duration = 45, Level = 1, Raiting = 5 }; //_autorsDb = new List<AuthorDb>() { // new AuthorDb(){ AuthorId = "id1", Name = "name1", Lastname = "lastname1", Annotation = "Annotation1", Professions = "Professions1", AuthorCourses = _coursesDb}, // new AuthorDb(){ AuthorId = "id2", Name = "name2", Lastname = "lastname2", Annotation = "Annotation2", Professions = "Professions2" }, // new AuthorDb(){ AuthorId = "id3", Name = "name3", Lastname = "lastname3", Annotation = "Annotation3", Professions = "Professions3" } //}.AsQueryable(); //_oneAuthorDb = new AuthorDb() { AuthorId = "id4", Name = "name4", Lastname = "lastname4", Annotation = "Annotation4", Professions = "Professions4" }; //_authorsInfo = new List<AuthorInfo>() { // new AuthorInfo(){ Name = "name1", Lastname = "lastname1", Annotation = "Annotation1", Professions = "Professions1" }, // new AuthorInfo(){ Name = "name2", Lastname = "lastname2", Annotation = "Annotation2", Professions = "Professions2" }, // new AuthorInfo(){ Name = "name3", Lastname = "lastname3", Annotation = "Annotation3", Professions = "Professions3" } //}.AsQueryable(); //_oneAuthorInfo = new AuthorInfo() { Name = "name4", Lastname = "lastname4", Annotation = "Annotation4", Professions = "Professions4" }; _mockSet = new Mock <DbSet <CourseDb> >(); _mockSet.As <IQueryable <CourseDb> >().Setup(m => m.Expression).Returns(_coursesDb.Expression); _mockSet.As <IQueryable <CourseDb> >().Setup(m => m.ElementType).Returns(_coursesDb.ElementType); _mockSet.As <IQueryable <CourseDb> >().Setup(m => m.GetEnumerator()).Returns(_coursesDb.GetEnumerator()); _mockContext = new Mock <VideoDbContext>(); _mockMapper = new Mock <IMapper>(); }
/// <summary> /// Create new course in repository. /// </summary> /// <param name="course"></param> /// <returns></returns> public async Task <CourseDb> AddAsync(CourseDb course) { _videoDbContext.Courses.Add(course); _videoDbContext.SaveChangesAsync().ConfigureAwait(false).GetAwaiter().GetResult(); return(await Task.FromResult(course)); }
/// <summary> /// Create new course in repository. /// </summary> /// <param name="course"></param> /// <returns></returns> public void Add(CourseDb course) { _videoDbContext.Courses.Add(course); _videoDbContext.SaveChanges(); }
protected override void Seed(BulbaCourses.Video.Data.DatabaseContext.VideoDbContext context) { // This method will be called after migrating to the latest version. #region Users var user1 = new UserDb() { UserId = Guid.NewGuid().ToString(), Login = "******", SubscriptionType = 1 }; var user2 = new UserDb() { UserId = Guid.NewGuid().ToString(), Login = "******", SubscriptionType = 1 }; context.Users.Add(user1); context.Users.Add(user2); #endregion #region Tags var tag1 = new TagDb() { TagId = Guid.NewGuid().ToString(), Content = "C#" }; List <TagDb> tagDbC = new List <TagDb>() { tag1 }; var tag2 = new TagDb() { TagId = Guid.NewGuid().ToString(), Content = "ASP.Net" }; List <TagDb> tagDbCSharp = new List <TagDb>() { tag1, tag2 }; var tag3 = new TagDb() { TagId = Guid.NewGuid().ToString(), Content = "Java" }; var tag4 = new TagDb() { TagId = Guid.NewGuid().ToString(), Content = "Automated" }; var tag5 = new TagDb() { TagId = Guid.NewGuid().ToString(), Content = "Testing" }; List <TagDb> tagDbJava = new List <TagDb>() { tag3, tag4, tag5 }; var tag6 = new TagDb() { TagId = Guid.NewGuid().ToString(), Content = "Network" }; var tag7 = new TagDb() { TagId = Guid.NewGuid().ToString(), Content = "DHCP" }; List <TagDb> tagDbNet = new List <TagDb>() { tag6, tag7 }; context.Tags.Add(tag1); context.Tags.Add(tag2); context.Tags.Add(tag3); context.Tags.Add(tag4); context.Tags.Add(tag5); context.Tags.Add(tag6); context.Tags.Add(tag7); #endregion #region Authors var author1 = new AuthorDb() { AuthorId = Guid.NewGuid().ToString(), Name = "Aleksandr", Lastname = "Shaduro", Annotation = "Experienced Instructor with a demonstrated history of working in the higher education industry. " + "Skilled in WEB Development, Agile Methodologies. Strong education professional graduated from Belarusian State University", Professions = "Chief Technical Officer at Artooba" }; var author2 = new AuthorDb() { AuthorId = Guid.NewGuid().ToString(), Name = "Aleksandr", Lastname = "Korablin", Annotation = "MCSD: MICROSOFT CERTIFIED SOLUTION DEVELOPER, ORACLE CERTIFIED ASSOCIATE, " + "JAVA SE 7 PROGRAMMER, WINDOWS AZURE DEVELOPER, MICROSOFT CERTIFIED TRAINER", Professions = "MICROSOFT CERTIFIED SOLUTION DEVELOPER" }; var author3 = new AuthorDb() { AuthorId = Guid.NewGuid().ToString(), Name = "Aleksandr", Lastname = "Borovoy", Annotation = "Local network, DHCP, DNS, NOD-32", Professions = "Local network" }; context.Authors.Add(author1); context.Authors.Add(author2); context.Authors.Add(author3); #endregion #region Courses var course1 = new CourseDb() { CourseId = Guid.NewGuid().ToString(), Name = "ASP by Shaduro", Author = author1, Level = 1, Raiting = 5, RateCount = 20, Description = ".NET is a developer platform made up of tools, programming languages, and libraries for building many different types of applications." + "ASP.NET extends the.NET developer platform with tools and libraries specifically for building web apps.", Date = DateTime.Now, Price = 850, Tags = tagDbCSharp }; var course2 = new CourseDb() { CourseId = Guid.NewGuid().ToString(), Name = "Programming in C#", Author = author1, Level = 1, Raiting = 4, RateCount = 12, Description = "C#(Sharp) is an object-oriented programming language developed by Microsoft.", Date = DateTime.Now, Price = 50, Tags = tagDbC }; var course3 = new CourseDb() { CourseId = Guid.NewGuid().ToString(), Name = "Java for Automated Testing", Author = author2, Level = 1, Raiting = 4, RateCount = 10, Description = "Test automation, a formalized testing process, can automate repetitive but necessary tasks that would be difficult to do manually.", Date = DateTime.Now, Price = 70, Tags = tagDbJava }; var course4 = new CourseDb() { CourseId = Guid.NewGuid().ToString(), Name = "Local Network", Author = author3, Level = 1, Raiting = 3, RateCount = 6, Description = "A local area network (LAN) is a computer network that interconnects computers within a limited area.", Date = DateTime.Now, Price = 10, Tags = tagDbNet }; context.Courses.Add(course1); context.Courses.Add(course2); context.Courses.Add(course3); context.Courses.Add(course4); #endregion #region Videos var video1 = new VideoMaterialDb() { VideoId = Guid.NewGuid().ToString(), Name = "validation", Url = @"D:\TestCourses\ASP by Shaduro\1_video_validation.mp4", Created = DateTime.Now, NumberOfViews = 1, Order = 1, CourseId = course1.CourseId }; var video2 = new VideoMaterialDb() { VideoId = Guid.NewGuid().ToString(), Name = "Refactiring & Security", Url = @"D:\TestCourses\ASP by Shaduro\2_video_refactiring_&_security.mp4", Created = DateTime.Now, NumberOfViews = 1, Order = 2, CourseId = course1.CourseId }; var video3 = new VideoMaterialDb() { VideoId = Guid.NewGuid().ToString(), Name = "Angular_Basic", Url = @"D:\TestCourses\ASP by Shaduro\3_video_angular_basic.mp4", Created = DateTime.Now, NumberOfViews = 1, Order = 3, CourseId = course1.CourseId }; var video4 = new VideoMaterialDb() { VideoId = Guid.NewGuid().ToString(), Name = "C# start part.1", Url = @"D:\TestCourses\Programming in C#\1_1_x264.mp4", Created = DateTime.Now, NumberOfViews = 1, Order = 1, CourseId = course2.CourseId }; var video5 = new VideoMaterialDb() { VideoId = Guid.NewGuid().ToString(), Name = "C# start part.1", Url = @"D:\TestCourses\Programming in C#\1_2_x264.mp4", Created = DateTime.Now, NumberOfViews = 1, Order = 2, CourseId = course2.CourseId }; var video6 = new VideoMaterialDb() { VideoId = Guid.NewGuid().ToString(), Name = "Java Fundamentals", Url = @"D:\TestCourses\Java for Automated Testing\01_Java Fundamentals.wmv", Created = DateTime.Now, NumberOfViews = 1, Order = 1, CourseId = course3.CourseId }; var video7 = new VideoMaterialDb() { VideoId = Guid.NewGuid().ToString(), Name = "Object Oriented Programming", Url = @"D:\TestCourses\Java for Automated Testing\02_Object Oriented Programming.wmv", Created = DateTime.Now, NumberOfViews = 1, Order = 2, CourseId = course3.CourseId }; var video8 = new VideoMaterialDb() { VideoId = Guid.NewGuid().ToString(), Name = "Numbers, strings, dates", Url = @"D:\TestCourses\Java for Automated Testing\03_Numbers, strings, dates.avi", Created = DateTime.Now, NumberOfViews = 1, Order = 3, CourseId = course3.CourseId }; var video9 = new VideoMaterialDb() { VideoId = Guid.NewGuid().ToString(), Name = "¬водный урок", Url = @"D:\TestCourses\Ћокальна¤ компьютерна¤ сеть\”рок 1 Ч ¬водный урок.avi", Created = DateTime.Now, NumberOfViews = 1, Order = 1, CourseId = course4.CourseId }; var video10 = new VideoMaterialDb() { VideoId = Guid.NewGuid().ToString(), Name = "«акрыта¤ серверна¤ стойка", Url = @"D:\TestCourses\Ћокальна¤ компьютерна¤ сеть\”рок 2 Ч ќбзор закрытой серверной стойки.avi", Created = DateTime.Now, NumberOfViews = 1, Order = 2, CourseId = course4.CourseId }; context.VideoMaterials.Add(video1); context.VideoMaterials.Add(video2); context.VideoMaterials.Add(video3); context.VideoMaterials.Add(video4); context.VideoMaterials.Add(video5); context.VideoMaterials.Add(video6); context.VideoMaterials.Add(video7); context.VideoMaterials.Add(video8); context.VideoMaterials.Add(video9); context.VideoMaterials.Add(video10); #endregion base.Seed(context); }
/// <summary> /// Remove course in repository. /// </summary> /// <param name="course"></param> /// <returns></returns> public void Remove(CourseDb course) { _videoDbContext.Courses.Remove(course); _videoDbContext.SaveChanges(); }