public ActionResult CreateCourse(CreateCourseBindingModel model)
        {
            model.Programs = Programs.Select(p => new SelectListItem {
                Value = p.ProgramId.ToString(),
                Text  = p.ProgramName
            }).ToList();

            model.Courses = Courses.Select(p => new SelectListItem {
                Value = p.CourseId.ToString(),
                Text  = p.CourseName
            }).ToList();

            model.Instructors = Instructors.Select(p => new SelectListItem
            {
                Value = p.InstructorId.ToString(),
                Text  = p.InstructorName
            }).ToList();

            model.Rooms = Rooms.Select(p => new SelectListItem
            {
                Value = p.RoomId.ToString(),
                Text  = p.RoomNumber
            }).ToList();

            return(View(model));
        }
        public ActionResult AllCourses(CreateCourseBindingModel model)
        {
            model.Programs = Programs.Select(p => new SelectListItem
            {
                Value = p.ProgramId.ToString(),
                Text  = p.ProgramName
            }).ToList();

            return(View(model));
        }
        public ActionResult Print(CreateCourseBindingModel model)
        {
            model.Instructors = Instructors.Select(p => new SelectListItem
            {
                Value = p.InstructorId.ToString(),
                Text  = p.InstructorName
            }).ToList();

            return(View(model));
        }
        public ActionResult RoomView(CreateCourseBindingModel model)
        {
            model.Rooms = Rooms.Select(p => new SelectListItem
            {
                Value = p.RoomId.ToString(),
                Text  = p.RoomNumber
            }).ToList();

            return(View(model));
        }
        public void Create_WithValidCourse_ShoudCallService()
        {
            // Arrange
            var model         = new CreateCourseBindingModel();
            var serviceCalled = false;

            this.courseServiceMock
            .Setup(repo => repo.AddCourseAsync(model))
            .Callback(() => serviceCalled = true);

            var controller = new CoursesController(this.courseServiceMock.Object, null, null);

            // Act
            var result = controller.Create(model);

            // Assert
            Assert.IsTrue(serviceCalled);
        }
Пример #6
0
        public async Task <IActionResult> Create(CreateCourseBindingModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View());
            }

            var course = await this.adminCoursesService.AddCourseAsync(model);

            this.logger.LogInformation(string.Format(AdminConstants.CreatedSuccessfullyCourse, course.Name));

            this.TempData.Put("__Message", new MessageModel
            {
                Type    = MessageType.Success,
                Message = string.Format(AdminConstants.CreatedSuccessfullyCourse, course.Name)
            });

            return(this.RedirectToAction("Details", new { id = course.Id }));
        }
Пример #7
0
        public async Task <IActionResult> Create(CreateCourseBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Alert = "Невалидни Данни!";
                return(Json("Invalid"));
            }

            try
            {
                var inputAsset = await this.azureMediaService.CreateInputAssetAsync(model.Video);

                var outputAsset = await this.azureMediaService.CreateOutputAssetAsync();

                var transform = await this.azureMediaService.GetOrCreateTransformAsync();

                var job = await this.azureMediaService.SubmitJobAsync(inputAsset.Name, outputAsset.Name, transform.Name);

                await this.azureMediaService.WaitForJobToFinishAsync(transform.Name, job.Name);

                var streamingLocator = await this.azureMediaService.CreateStreamingLocatorAsync(outputAsset.Name);

                var getStreamingUrls = await this.azureMediaService.GetStreamingUrlsAsync(streamingLocator.Name);

                await this.azureMediaService.CleanUpAsync(transform.Name, inputAsset.Name);

                var user = await this.userManager.GetUserAsync(this.User);

                var imageUrl = await this.azureStorageBlobService.UploadImageAsync(model.Image);

                var courseId = await this.coursesService.CreateAsync(model, user.Id, user.FirstName, user.LastName, imageUrl);

                await this.reviewService.SaveReviewDbAsync(courseId, outputAsset.Name, getStreamingUrls[2]);

                return(Json("Valid"));
            }
            catch
            {
                throw new InvalidOperationException("Неуспешно добаване в AzureMedia");
            }
        }
Пример #8
0
        public async Task <int> CreateAsync(CreateCourseBindingModel model, string userId, string userFirstName, string userLastName, string imageUrl)
        {
            var course = new Course
            {
                Name               = model.Name,
                Description        = model.Description,
                Price              = model.Price,
                Category           = model.Category,
                Image              = imageUrl,
                Skills             = model.Skills,
                CreatedOn          = DateTime.UtcNow,
                InstructorFullName = userFirstName + ' ' + userLastName,
                InstructorId       = userId
            };

            var item = await this.db.Courses.AddAsync(course);

            await this.db.SaveChangesAsync();

            var courseId = item.Entity.Id;

            return(courseId);
        }
Пример #9
0
        public async Task CreateCourseShouldCorrectly()
        {
            var categoryDevelopment = (Category)Enum.Parse(typeof(Category), "Програмиране");

            var image = new Mock <IFormFile>().Object;

            var model = new CreateCourseBindingModel
            {
                Name               = "Kris",
                Description        = "qwqwqwqwqwqwqwqwqwqwqwqwq",
                Price              = 50,
                Skills             = "test",
                Category           = categoryDevelopment,
                Image              = image,
                InstructorFullName = "InstructorName",
                InstructorId       = "1"
            };

            await this.coursesService.CreateAsync(model, "1", "Pesho", "Ivanov", "imageUrl");

            int actual = db.Courses.ToList().Count();

            Assert.Equal(1, actual);
        }