// Create Lectures public int createLecture(lectureModel lectureData, bool feed, DateTime endDate) { int result = 0; using (myProjectEntities context = new myProjectEntities()) { lectureData.lecture_status = 1; Mapper.CreateMap <lectureModel, tblLecture>(); tblLecture newLec = Mapper.Map <lectureModel, tblLecture>(lectureData); context.tblLectures.Add(newLec); int qq = context.SaveChanges(); result = qq; if (feed) { feedbackModel feedModel = new feedbackModel(); feedModel.FK_Lecture_id = newLec.PK_Lecture_id; feedModel.end_date = endDate; qq = createFeedback(feedModel); } return(result); } }
//Update Lecture data public bool updateLecture(lectureModel lectureData) { bool result = false; using (myProjectEntities context = new myProjectEntities()) { Mapper.CreateMap <lectureModel, tblLecture>(); tblLecture s = Mapper.Map <lectureModel, tblLecture>(lectureData); context.Entry(s).State = EntityState.Modified; int q = context.SaveChanges(); if (q == 1) { result = true; } return(result); } }