public Models.Lookup.CourseModel GetCourseByID(int CourseID)
        {
            BusinessLogic.Lookup.CourseManager CourseManager = new BusinessLogic.Lookup.CourseManager();
            BusinessEntity.Lookup.CourseEntity Course        = CourseManager.GetCourseByID(CourseID);

            return(new Models.Lookup.CourseModel(Course));
        }
        public BusinessEntity.Result DeleteCourse(BusinessEntity.Lookup.CourseEntity Course)
        {
            BusinessEntity.Result result = new BusinessEntity.Result();
            try
            {
                SchoolInformationManagementSystemDBEntities e = new SchoolInformationManagementSystemDBEntities();
                var original = e.tblCourses.Find(Course.ID);
                if (original != null)
                {
                    e.tblCourses.Remove(e.tblCourses.Where(x => x.ID == Course.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 UpdateCourse(BusinessEntity.Lookup.CourseEntity Course)
        {
            BusinessEntity.Result result = new BusinessEntity.Result();
            try
            {
                SchoolInformationManagementSystemDBEntities e = new SchoolInformationManagementSystemDBEntities();
                var original = e.tblCourses.Find(Course.ID);
                if (original != null)
                {
                    e.Entry(original).CurrentValues.SetValues(Course);
                    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 CourseModel(BusinessEntity.Lookup.CourseEntity course)
 {
     this.ID          = course.ID;
     this.Name        = course.Name;
     this.Description = course.Description;
     this.CreatedBy   = course.CreatedBy;
     this.CreatedDate = course.CreatedDate;
 }
        public T MapToEntity <T>() where T : class
        {
            BusinessEntity.Lookup.CourseEntity course = new BusinessEntity.Lookup.CourseEntity();
            course.ID          = this.ID;
            course.Name        = this.Name;
            course.Description = this.Description;
            course.CreatedBy   = this.CreatedBy;
            course.CreatedDate = this.CreatedDate;

            return(course as T);
        }
        public BusinessEntity.Result SaveCourse(BusinessEntity.Lookup.CourseEntity Course)
        {
            BusinessEntity.Result result = new BusinessEntity.Result();
            try
            {
                SchoolInformationManagementSystemDBEntities e = new SchoolInformationManagementSystemDBEntities();
                e.tblCourses.Add(Course.MapToModel <DataAccessLogic.tblCourse>());
                e.SaveChanges();

                result.Message = "Saved Successfully.";
                result.Status  = true;
                return(result);
            }
            catch (Exception)
            {
                result.Message = "Failed to save";
                result.Status  = false;
                return(result);
            }
        }