// 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)); } }
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(); }
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; } }
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(); }
public void UnRegisterStudentOnCourse(LearningObjectDTO lo, StudentDTO student) { throw new NotImplementedException(); }
public void TakeCourseOnline(LearningObjectDTO lo) { throw new NotImplementedException(); }