/////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// public JsonResult GetLessonPlanInfo(int id) { var LessonPlan = db.AspNetLessonPlans.FirstOrDefault(d => d.Id == id); lessonPlan Info = new lessonPlan(); Info.GetTopics = new List <string>(); Info.BreakDown = new List <BreakDowns>(); Info.classID = Convert.ToInt32(LessonPlan.AspNetSubject.AspNetClass.Id); Info.subjectID = Convert.ToInt32(LessonPlan.SubjectID); Info.Date = Convert.ToDateTime(LessonPlan.Date); Info.Duration = Convert.ToInt32(LessonPlan.Duration); Info.lessonPlanNo = Convert.ToInt32(LessonPlan.LessonPlanNo); foreach (var topic in LessonPlan.AspNetLessonPlan_Topic) { Info.GetTopics.Add(topic.AspNetTopic.TopicName); } foreach (var breakdown in LessonPlan.AspNetLessonPlanBreakdowns) { BreakDowns breakDown = new BreakDowns(); breakDown.Id = breakdown.Id; breakDown.HeadingName = breakdown.AspNetLessonPlanBreakdownHeading.BreakDownHeadingName; breakDown.Description = WebUtility.HtmlDecode(breakdown.Description); breakDown.Minutes = Convert.ToInt32(breakdown.Minutes); breakDown.Resources = breakdown.Resources; Info.BreakDown.Add(breakDown); } return(Json(Info, JsonRequestBehavior.AllowGet)); }
public JsonResult GetLessonPlanFromID(int Id) { var tempLessonPlan = db.AspNetLessonPlans.Where(x => x.Id == Id).FirstOrDefault(); lessonPlan LessonPlan = new lessonPlan(); LessonPlan.GetTopics = new List <string>(); LessonPlan.BreakDown = new List <BreakDowns>(); LessonPlan.classID = tempLessonPlan.AspNetSubject.AspNetClass.Id; LessonPlan.subjectID = tempLessonPlan.AspNetSubject.Id; LessonPlan.className = tempLessonPlan.AspNetSubject.AspNetClass.ClassName; LessonPlan.subjectName = tempLessonPlan.AspNetSubject.SubjectName; foreach (var topic in tempLessonPlan.AspNetLessonPlan_Topic) { LessonPlan.GetTopics.Add(topic.AspNetTopic.TopicName); } foreach (var breakdown in tempLessonPlan.AspNetLessonPlanBreakdowns) { BreakDowns breakDown = new BreakDowns(); breakDown.Id = breakdown.Id; breakDown.HeadingName = breakdown.AspNetLessonPlanBreakdownHeading.BreakDownHeadingName; breakDown.Description = WebUtility.HtmlDecode(breakdown.Description); breakDown.Minutes = Convert.ToInt32(breakdown.Minutes); breakDown.Resources = breakdown.Resources; LessonPlan.BreakDown.Add(breakDown); } LessonPlan.Date = Convert.ToDateTime(tempLessonPlan.Date); LessonPlan.Duration = Convert.ToInt32(tempLessonPlan.Duration); return(Json(LessonPlan, JsonRequestBehavior.AllowGet)); }
public void EditLessonPlanobj(lessonPlan LessonPlan) { var lessonPlanToEdit = db.AspNetLessonPlans.FirstOrDefault(s => s.Date == LessonPlan.Date && s.SubjectID == LessonPlan.subjectID); AspNetLessonPlan aspNetLessonPlan = db.AspNetLessonPlans.FirstOrDefault(x => x.Id == lessonPlanToEdit.Id); aspNetLessonPlan.LessonPlanNo = LessonPlan.lessonPlanNo; aspNetLessonPlan.SubjectID = LessonPlan.subjectID; aspNetLessonPlan.Date = LessonPlan.Date; aspNetLessonPlan.Duration = LessonPlan.Duration; //db.AspNetLessonPlans.Add(aspNetLessonPlan); db.SaveChanges(); int LessonPlanID = db.AspNetLessonPlans.Max(x => x.Id); foreach (var topic in LessonPlan.Topics) { AspNetLessonPlan_Topic lessonPlanTopicExist = db.AspNetLessonPlan_Topic.FirstOrDefault(x => x.TopicID == topic && x.LessonPlanID == LessonPlanID); if (lessonPlanTopicExist == null) { AspNetLessonPlan_Topic lessonPlanTopic = new AspNetLessonPlan_Topic(); lessonPlanTopic.TopicID = topic; lessonPlanTopic.LessonPlanID = LessonPlanID; db.AspNetLessonPlan_Topic.Add(lessonPlanTopic); db.SaveChanges(); } } foreach (var breakdown in LessonPlan.BreakDown) { AspNetLessonPlanBreakdown BreakdownCheck = db.AspNetLessonPlanBreakdowns.FirstOrDefault(x => x.BreakDownHeadingID == breakdown.HeadingID && x.LessonPlanID == LessonPlanID); if (BreakdownCheck == null) { AspNetLessonPlanBreakdown aspNetLessonBreakdown = new AspNetLessonPlanBreakdown(); aspNetLessonBreakdown.LessonPlanID = LessonPlanID; aspNetLessonBreakdown.Minutes = breakdown.Minutes; aspNetLessonBreakdown.Resources = breakdown.Resources; aspNetLessonBreakdown.BreakDownHeadingID = breakdown.HeadingID; aspNetLessonBreakdown.Description = WebUtility.HtmlEncode(breakdown.Description).ToString(); db.AspNetLessonPlanBreakdowns.Add(aspNetLessonBreakdown); db.SaveChanges(); } else { BreakdownCheck.Minutes = breakdown.Minutes; BreakdownCheck.BreakDownHeadingID = breakdown.HeadingID; BreakdownCheck.Description = breakdown.Description; db.SaveChanges(); } } }
partial void DeletelessonPlan(lessonPlan instance);
partial void UpdatelessonPlan(lessonPlan instance);
partial void InsertlessonPlan(lessonPlan instance);
public bool isLessonplanUpdated( int lessonplan_ID, int t_ID, int s_ID, DateTime Sdate, DateTime fdate, string duration, string topic, string stopic, int formClass_ID, string preKnow, string content, string intro, string eval ) { try { lessonPlan updatedPlan = new lessonPlan() { teacher_ID = t_ID, subject_ID = s_ID, startDate = Sdate, endDate = fdate, duration = duration, topic = topic, subtopic = stopic, formClass_ID = formClass_ID, PreviousKnowledge = preKnow, plannedContent = content, introduction = intro, evaluations = eval, lessonPlan_ID = lessonplan_ID }; lessonPlan oldPlan = (from p in MOE_DB.lessonPlans where p.lessonPlan_ID == lessonplan_ID select p).Single(); oldPlan = updatedPlan; MOE_DB.SubmitChanges(); return true; } catch (Exception ex) { return false; }//try catch }
public bool isLessonplanAdded( int t_ID, int s_ID, DateTime Sdate, DateTime fdate, string duration, string topic, string stopic, int formClass_ID, string preKnow, string content, string intro, string eval ) { try { lessonPlan newPlan = new lessonPlan() { teacher_ID = t_ID, subject_ID = s_ID, startDate = Sdate, endDate = fdate, duration = duration, topic = topic, subtopic = stopic, formClass_ID = formClass_ID, PreviousKnowledge = preKnow, plannedContent = content, introduction = intro, evaluations = eval }; MOE_DB.lessonPlans.InsertOnSubmit( newPlan ); MOE_DB.SubmitChanges(); return true; } catch (Exception ex) { return false; }//try catch }
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public JsonResult AddLessonPlan(lessonPlan LessonPlan) { var TransactionObj = db.Database.BeginTransaction(); try { AspNetLessonPlan aspNetLessonPlan = new AspNetLessonPlan(); aspNetLessonPlan.LessonPlanNo = LessonPlan.lessonPlanNo; aspNetLessonPlan.SubjectID = LessonPlan.subjectID; aspNetLessonPlan.Date = LessonPlan.Date; aspNetLessonPlan.Duration = LessonPlan.Duration; db.AspNetLessonPlans.Add(aspNetLessonPlan); db.SaveChanges(); int LessonPlanID = db.AspNetLessonPlans.Max(x => x.Id); foreach (var topic in LessonPlan.Topics) { AspNetLessonPlan_Topic lessonPlanTopic = new AspNetLessonPlan_Topic(); lessonPlanTopic.TopicID = topic; lessonPlanTopic.LessonPlanID = LessonPlanID; db.AspNetLessonPlan_Topic.Add(lessonPlanTopic); db.SaveChanges(); } if (LessonPlan.BreakDown != null) { foreach (var breakdown in LessonPlan.BreakDown) { AspNetLessonPlanBreakdown aspNetLessonBreakdown = new AspNetLessonPlanBreakdown(); aspNetLessonBreakdown.LessonPlanID = LessonPlanID; aspNetLessonBreakdown.Minutes = breakdown.Minutes; aspNetLessonBreakdown.Resources = breakdown.Resources; aspNetLessonBreakdown.BreakDownHeadingID = breakdown.HeadingID; aspNetLessonBreakdown.Description = WebUtility.HtmlEncode(breakdown.Description).ToString(); db.AspNetLessonPlanBreakdowns.Add(aspNetLessonBreakdown); db.SaveChanges(); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var UserNameLog = User.Identity.Name; AspNetUser a = db.AspNetUsers.First(x => x.UserName == UserNameLog); string UserIDLog = a.Id; var logMessage = "New LessonPlan Added, SubjectID: " + LessonPlan.subjectID + ", Date: " + LessonPlan.Date; var LogControllerObj = new AspNetLogsController(); LogControllerObj.CreateLogSave(logMessage, UserIDLog); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// db.SaveChanges(); TransactionObj.Commit(); } catch (Exception) { TransactionObj.Dispose(); } return(Json("data", JsonRequestBehavior.AllowGet)); }