public IActionResult InsertLesson(string id, string name, string year, string audioURLOnline, string audioURLDowload, string imageURL, string transcript, string actor, string summary, string vocabulary, string createdDate) { try { var lesson = dataContext.Lessons.FirstOrDefault(); if (lesson != null) { lesson.ID = RandomObject.RandomString(20); lesson.Name = name; lesson.IDTP = TempData["topicID"].ToString(); lesson.Year = Int32.Parse(year); lesson.FileURLOnline = audioURLOnline; lesson.FileURLDowload = audioURLDowload; lesson.ImageURL = imageURL; lesson.Transcript = transcript; lesson.Actor = actor; lesson.Sumary = summary; lesson.Vocabulary = vocabulary; lesson.CreatedDate = (DateTime.Now).ToString(); lesson.UpdatedDate = null; } dataContext.Lessons.Add(lesson); dataContext.SaveChangesAsync(); return(RedirectToAction("HomePage")); } catch (Exception ex) { } return(RedirectToAction("ToCreateLessonPage")); }