Esempio n. 1
0
 // GET: Course/Edit/5
 public ActionResult Edit(int id)
 {
     try
     {
         LearningObjectDTO lo = _courseService.GetCourse(id);
         Mapper.Initialize(cfg => cfg.CreateMap <LearningObjectDTO, CourseViewModel>()
                           .ForMember("Id", opt => opt.MapFrom(src => src.Id)));
         var course = Mapper.Map <LearningObjectDTO, CourseViewModel>(lo);
         return(View(course));
     }
     catch (ValidationException ex)
     {
         return(Content(ex.Message));
     }
 }
Esempio n. 2
0
        public void CreateNewCourse(LearningObjectDTO lo)
        {
            if (string.IsNullOrEmpty(lo.Name))
            {
                throw new ValidationException("Course Name cannot be empty", "");
            }

            if (string.IsNullOrEmpty(lo.Company))
            {
                throw new ValidationException("Course Company cannot be empty", "");
            }

            _unitOfWork.LearningObjects.Create(new LearningObject {
                Name = lo.Name, Description = lo.Company
            });
            _unitOfWork.Save();
        }
Esempio n. 3
0
        public LearningObjectVM(LearningObjectDTO lo)
        {
            Id = lo.Id;
            switch (lo)
            {
            case TextDTO text:
                TextVisibility = Visibility.Visible;
                Text           = text.Content;
                break;

            case ImageDTO image:
                ImageVisibility = Visibility.Visible;
                Url             = image.Url;
                Caption         = image.Caption;
                break;

            case VideoDTO video:
                VideoVisibility = Visibility.Visible;
                Url             = video.Url;
                break;
            }
        }
Esempio n. 4
0
        public void UpdateCourse(LearningObjectDTO lo)
        {
            if (lo.Id <= 0)
            {
                throw new ValidationException("Course Id cannot be empty", "");
            }

            if (string.IsNullOrEmpty(lo.Name))
            {
                throw new ValidationException("Course Name cannot be empty", "");
            }

            if (string.IsNullOrEmpty(lo.Company))
            {
                throw new ValidationException("Course Company cannot be empty", "");
            }
            var objToUpdate = _unitOfWork.LearningObjects.Get(lo.Id);

            objToUpdate.Name        = lo.Name;
            objToUpdate.Description = lo.Company;
            _unitOfWork.LearningObjects.Update(objToUpdate);
            _unitOfWork.Save();
        }
Esempio n. 5
0
 public void UnRegisterStudentOnCourse(LearningObjectDTO lo, StudentDTO student)
 {
     throw new NotImplementedException();
 }
Esempio n. 6
0
 public void TakeCourseOnline(LearningObjectDTO lo)
 {
     throw new NotImplementedException();
 }