public ResultViewModel <TrackCourseEditViewModel> Post(TrackCourseEditViewModel TrackCourse) { ResultViewModel <TrackCourseEditViewModel> result = new ResultViewModel <TrackCourseEditViewModel>(); try { if (!ModelState.IsValid) { result.Message = "In Valid Model State"; } else { TrackCourseEditViewModel selectedTrackCourse = TrackCourseService.Add(TrackCourse); var Users = userTrackService.GetAll().Where(i => i.TrackID == TrackCourse.TrackID).Select(i => i.UserID); Hub.Clients.All.NewCourseAdded(new { Users, CourseName = courseService.GetByID(TrackCourse.CourseID).Name, TrackName = TrackService.GetByID(TrackCourse.TrackID).Name }); result.Successed = true; result.Data = selectedTrackCourse; } } catch (Exception ex) { result.Successed = false; result.Message = "Semething Went Wrong"; } return(result); }
public ResultViewModel <IEnumerable <UserTrackViewModel> > GetList() { ResultViewModel <IEnumerable <UserTrackViewModel> > result = new ResultViewModel <IEnumerable <UserTrackViewModel> >(); try { var UserTracks = UserTrackService.GetAll(pageIndex: 0); result.Successed = true; result.Data = UserTracks; } catch (Exception ex) { result.Successed = false; result.Message = "Something Went Wrong !!"; } return(result); }