public Models.Tutorial.TeacherTutorialModel GetTeacherTutorialByID(int TeacherTutorialID) { BusinessLogic.Tutorial.TeacherTutorialManager TeacherTutorialManager = new BusinessLogic.Tutorial.TeacherTutorialManager(); BusinessEntity.Tutorial.TeacherTutorialEntity TeacherTutorial = TeacherTutorialManager.GetTeacherTutorialByID(TeacherTutorialID); return(new Models.Tutorial.TeacherTutorialModel(TeacherTutorial)); }
public BusinessEntity.Result DeleteTeacherTutorial(BusinessEntity.Tutorial.TeacherTutorialEntity TeacherTutorial) { BusinessEntity.Result result = new BusinessEntity.Result(); try { SchoolInformationManagementSystemDBEntities e = new SchoolInformationManagementSystemDBEntities(); var original = e.tblTeacherTutorials.Find(TeacherTutorial.ID); if (original != null) { e.tblTeacherTutorials.Remove(e.tblTeacherTutorials.Where(x => x.ID == TeacherTutorial.ID).First()); e.SaveChanges(); result.Message = "Deleted Successfully."; result.Status = true; return(result); } else { result.Message = "Failed to delete"; result.Status = false; return(result); } } catch (Exception) { result.Message = "Failed to delete"; result.Status = false; return(result); } }
public BusinessEntity.Result UpdateTeacherTutorial(BusinessEntity.Tutorial.TeacherTutorialEntity TeacherTutorial) { BusinessEntity.Result result = new BusinessEntity.Result(); try { SchoolInformationManagementSystemDBEntities e = new SchoolInformationManagementSystemDBEntities(); var original = e.tblTeacherTutorials.Find(TeacherTutorial.ID); if (original != null) { e.Entry(original).CurrentValues.SetValues(TeacherTutorial); e.SaveChanges(); result.Message = "Updated Successfully."; result.Status = true; return(result); } else { result.Message = "Failed to update"; result.Status = false; return(result); } } catch (Exception) { result.Message = "Failed to update"; result.Status = false; return(result); } }
public TeacherTutorialModel(BusinessEntity.Tutorial.TeacherTutorialEntity teacherTutorial) { this.ID = teacherTutorial.ID; this.AcademicYear = teacherTutorial.AcademicYear; this.Teacher = new TeacherModel(teacherTutorial.Teacher); this.CreatedBy = teacherTutorial.CreatedBy; this.CreatedDate = teacherTutorial.CreatedDate; this.UpdatedBy = teacherTutorial.UpdatedBy; this.UpdatedDate = teacherTutorial.UpdatedDate; }
public T MapToEntity <T>() where T : class { BusinessEntity.Tutorial.TeacherTutorialEntity teacherTutorial = new BusinessEntity.Tutorial.TeacherTutorialEntity(); teacherTutorial.ID = this.ID; teacherTutorial.AcademicYear = this.AcademicYear; teacherTutorial.Teacher = this.Teacher.MapToEntity <BusinessEntity.Admission.TeacherEntity>(); teacherTutorial.CreatedBy = this.CreatedBy; teacherTutorial.CreatedDate = this.CreatedDate; teacherTutorial.UpdatedBy = this.UpdatedBy; teacherTutorial.UpdatedDate = this.UpdatedDate; return(teacherTutorial as T); }
public BusinessEntity.Result SaveTeacherTutorial(BusinessEntity.Tutorial.TeacherTutorialEntity TeacherTutorial) { BusinessEntity.Result result = new BusinessEntity.Result(); try { SchoolInformationManagementSystemDBEntities e = new SchoolInformationManagementSystemDBEntities(); e.tblTeacherTutorials.Add(TeacherTutorial.MapToModel <DataAccessLogic.tblTeacherTutorial>()); e.SaveChanges(); result.Message = "Saved Successfully."; result.Status = true; return(result); } catch (Exception) { result.Message = "Failed to save"; result.Status = false; return(result); } }