public ActionResult Create([Bind(Include = "CoursePlaylistId,CourseId,PlaylistId,PlaylistName")] CoursePlaylist coursePlaylist) { if (ModelState.IsValid) { db.CoursePlaylists.Add(coursePlaylist); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseId = new SelectList(db.Courses, "Id", "Title", coursePlaylist.CourseId); return(View(coursePlaylist)); }
public async Task <ActionResult> Create([Bind(Include = "Id,CourseId,BroadcastId,BroadcastKind,BroadcastTitle,BroadcastDescription,BroadcastScheduledStartTime,BroadcastScheduledEndTime,BroadcastStatus,BroadcastchannelId,BroadcastlifeCycleStatus,BroadcastEmbededhtml,StreamId,StreamKind,StreamName,StreamStatus,StreamSnippetTitle,StreamCDNFormat,StreamCDNIngestionType,StreamCDNIngestionUrl,StreamcontentclosedCaptionsIngestionUrl")] YoutubeLiveDetail youtubelivedetail) { BroadcastController liveController = new BroadcastController(); youtubelivedetail.StreamCDNIngestionType = "rtmp"; youtubelivedetail.BroadcastKind = "youtube#liveBroadcast"; youtubelivedetail.StreamKind = "youtube#liveStream"; // Create broadcast and stream for YoutubeLive LiveBroadcast broadcast = await liveController.createBroadcast(youtubelivedetail.BroadcastKind, youtubelivedetail.BroadcastTitle, youtubelivedetail.BroadcastScheduledStartTime, youtubelivedetail.BroadcastScheduledEndTime, youtubelivedetail.BroadcastStatus); LiveStream stream = await liveController.createStream(youtubelivedetail.StreamKind, youtubelivedetail.StreamSnippetTitle, youtubelivedetail.StreamCDNFormat, youtubelivedetail.StreamCDNIngestionType); // Bind them together LiveBroadcast bindedBroadcast = await liveController.bindBroadcast(broadcast, stream); // Values to-be inserted updated youtubelivedetail.BroadcastId = bindedBroadcast.Id; youtubelivedetail.BroadcastchannelId = bindedBroadcast.ContentDetails.BoundStreamId; youtubelivedetail.StreamName = stream.Cdn.IngestionInfo.StreamName; youtubelivedetail.StreamStatus = stream.Status.StreamStatus; youtubelivedetail.StreamId = stream.Id; youtubelivedetail.StreamCDNIngestionUrl = stream.Cdn.IngestionInfo.IngestionAddress; String id = (bindedBroadcast.ContentDetails.MonitorStream.EmbedHtml).ToString(); YouTubeService youtube = new YouTubeService(await(new GoogleAuthentication()).GetInitializer()); bindedBroadcast.ContentDetails.MonitorStream.EnableMonitorStream = false; LiveBroadcastsResource.UpdateRequest disablePreview = youtube.LiveBroadcasts.Update(bindedBroadcast, "contentDetails"); LiveBroadcast returnBroadcast = disablePreview.Execute(); //substring for browser if (id.Contains("embed/")) { int startIndex = id.IndexOf("embed/"); int endIndex = id.IndexOf("?"); id = id.Substring(startIndex + 6, (endIndex - (startIndex + 6))); } youtubelivedetail.BroadcastEmbededhtml = id; //BroadCastID for Player if (ModelState.IsValid) { db.YoutubeLiveDetails.Add(youtubelivedetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseId = new SelectList(db.Courses, "Id", "Title", youtubelivedetail.CourseId); return(View(youtubelivedetail)); }
public ActionResult Create([Bind(Include = "Id,CourseId,ProfessorId,OfficeLocation,OfficePhone,CellPhone,EmergencyPhone,EmailAddress,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday,MeetingTime,isActive")] Syllabus syllabus) { if (ModelState.IsValid) { db.Syllabi.Add(syllabus); db.SaveChanges(); return(RedirectToAction("Index")); } var userId = User.Identity.GetUserId(); ViewBag.CourseId = new SelectList(db.Courses, "Id", "Title", syllabus.CourseId); ViewBag.ProfessorId = new SelectList(db.Users.Where(q => (db.UserRelationships.Where(x => x.AccountId == userId).Select(x => x.AccountId)).Contains(q.Id)), "Id", "UserName", syllabus.ProfessorId); return(View(syllabus)); }
public ActionResult Create(string start, string end, string text) { var toBeCreated = new ClassDate(); toBeCreated.StartDate = Convert.ToDateTime(start); toBeCreated.EndDate = Convert.ToDateTime(end); toBeCreated.Title = text; toBeCreated.isActive = true; db.ClassDates.Add(toBeCreated); db.SaveChanges(); return(new JsonResult { Data = new Dictionary <string, object> { { "id", toBeCreated.Id } } }); }
public ActionResult Create([Bind(Include = "Id,Subject,CourseNumber,Section,Title,StartDate,EndDate,Location,Term,CreatedBy,CreateDate,ModifedBy,ModifiedDate")] Course course) { course.CreatedBy = Account.UserManager.FindById(User.Identity.GetUserId()); if (ModelState.IsValid) { UserRelationship _UserRelationship = new UserRelationship() { Account = course.CreatedBy, AccountRole = Database.Helpers.CourseRole.owner }; db.UserRelationships.Add(_UserRelationship); course.UserRelationships.Add(_UserRelationship); db.Courses.Add(course); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(course)); }
public ActionResult Create([Bind(Include = "Id,PublishOn,NewsTitle,NewsText,CourseId")] Announcement announcement) { announcement.CreatedBy = User.Identity.GetUserId(); announcement.IsActive = true; ModelState.Clear(); TryValidateModel(announcement); if (ModelState.IsValid) { db.Announcements.Add(announcement); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseId = new SelectList(db.Courses, "Id", "Title", announcement.CourseId); return(View(announcement)); }
public string DeleteUserFromCourse(RemoveUserFromCourse model) { if (ModelState.IsValid) { if (User.Identity.GetUserId().Equals(model.AccountId)) { //user is not in course Response.StatusCode = 400; return("You can't remove your self "); } if (!db.Courses.ToList().Any(obj => obj.UserRelationships.Any(u => u.AccountId.Equals(model.AccountId)))) { //user is not in course Response.StatusCode = 400; return("User is not part of this course"); } if (db.Courses.ToList().Any(obj => obj.UserRelationships.Any(u => u.AccountId.Equals(User.Identity.GetUserId()) && u.AccountRole == CourseRole.owner))) { var course = db.Courses.Find(model.CourseId).UserRelationships.Where(obj => obj.AccountId.Equals(model.AccountId) && obj.Course.Id == model.CourseId).ToList(); if (!(course.Count > 0)) { //course is not found Response.StatusCode = 400; return("Error removing user"); } var c = db.UserRelationships.Where(obj => obj.AccountId.Equals(model.AccountId) && obj.Course.Id.Equals(model.CourseId)).FirstOrDefault(); foreach (var r in course) { r.IsActive = false; r.ModifedBy = User.Identity.GetUserId(); r.ModifiedDate = DateTime.Now; } db.SaveChanges(); Response.StatusCode = 200; return("User " + db.Users.Find(model.AccountId).UserName + " has been removed."); } else { Response.StatusCode = 403; return("You can not make changes to this course"); } } Response.StatusCode = 400; return("All values are required"); }