예제 #1
0
        public ActionResult Create(Enrollment enrollment)
        {
            try
            {
                enrollment.CourseId    = 1;
                enrollment.StudentId   = 6;
                enrollment.CreatedDate = DateTime.Now;
                enrollment.UpdatedDate = DateTime.Now;

                _enrollmentService.AddEnrollment(enrollment);

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(View());
            }
        }
예제 #2
0
        public void AddEnrollment()
        {
            IEnrollmentService enrollmentService = new EnrollmentService(new PlugUnitOfWork(new PlugDbContextFactory()));
            ICourseService     courseService     = new CourseService(new PlugUnitOfWork(new PlugDbContextFactory()));

            var courseModels = courseService.GetCourses(new Plug.Models.Input <System.Guid>
            {
                Arguments = new System.Guid("66EA3A48-49E7-41D4-B36A-BBD86922FAC5")
            });
            var courseModel = courseModels.Result.FirstOrDefault();

            var outputResult = enrollmentService.AddEnrollment(new Plug.Models.Input <Plug.Models.EnrollmentModel>
            {
                OperationBy = "UnitTest",
                Arguments   = new Plug.Models.EnrollmentModel
                {
                    StudentId = new System.Guid("66EA3A48-49E7-41D4-B36A-BBD86922FAC5"),
                    CourseId  = courseModel.Id,
                }
            });

            Assert.IsTrue(outputResult.Result.Sucess);
        }