public async Task CreateLecture(LectureCreateModel lectureCreateModel) { _repository.CreateLecture(Lecture.CreateLecture( lectureCreateModel.Title, lectureCreateModel.Description) ); var currentLecture = GetLectureInfoByDetails(lectureCreateModel.Title, lectureCreateModel.Description); if (lectureCreateModel.File != null) { foreach (var file in lectureCreateModel.File) { if (file.Length > 0) { string path = Path.Combine(_env.WebRootPath, "Lectures/" + currentLecture.Id); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } // string extension = lectureCreateModel.Title + "." + Path.GetExtension(file.FileName).Substring(1); using (var fileStream = new FileStream(Path.Combine(path, file.FileName), FileMode.Create)) { await file.CopyToAsync(fileStream); } } } } }
public LectureRepositoryMock() { Lectures = new List <Lecture> { Lecture.CreateLecture("Title1", "Description1"), Lecture.CreateLecture("Title2", "Description2"), Lecture.CreateLecture("Title3", "Description3"), Lecture.CreateLecture("Title4", "Description4"), Lecture.CreateLecture("Title5", "Description5") }; Lectures[0].Id = new Guid("e7c51c3a-3f56-40a7-832c-96246fdfe986"); Lectures[1].Id = new Guid("d3ba2f3b-2a1f-4175-bc05-a0a89a14942d"); }
public void DeleteLecture_GivendDetails_EliminateTheLecture() { // Arrange var sut = CreateSut(); var lecture = Lecture.CreateLecture("B-Bam", "Description"); Mock.Lectures.Add(lecture); // Act sut.DeleteLecture(lecture); // Assert Assert.AreEqual(Mock.Lectures.Count, 5); }