public BusinessEntity.Result DeleteStudent(BusinessEntity.Admission.StudentEntity Student)
        {
            BusinessEntity.Result result = new BusinessEntity.Result();
            try
            {
                SchoolInformationManagementSystemDBEntities e = new SchoolInformationManagementSystemDBEntities();
                var original = e.tblStudents.Find(Student.ID);
                if (original != null)
                {
                    e.tblStudents.Remove(e.tblStudents.Where(x => x.ID == Student.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 UpdateStudent(BusinessEntity.Admission.StudentEntity Student)
        {
            BusinessEntity.Result result = new BusinessEntity.Result();
            try
            {
                SchoolInformationManagementSystemDBEntities e = new SchoolInformationManagementSystemDBEntities();
                var original = e.tblStudents.Find(Student.ID);
                if (original != null)
                {
                    e.Entry(original).CurrentValues.SetValues(Student);
                    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);
            }
        }
Пример #3
0
        public Models.Admission.StudentModel GetStudentByID(int StudentID)
        {
            BusinessLogic.Admission.StudentManager StudentManager = new BusinessLogic.Admission.StudentManager();
            BusinessEntity.Admission.StudentEntity Student        = StudentManager.GetStudentByID(StudentID);

            return(new Models.Admission.StudentModel(Student));
        }
        public T MapToEntity <T>() where T : class
        {
            BusinessEntity.Admission.StudentEntity student = new BusinessEntity.Admission.StudentEntity();
            student.ID            = this.ID;
            student.Fullname      = this.Fullname;
            student.MotherName    = this.MotherName;
            student.BirthDate     = this.BirthDate;
            student.HouseNo       = this.HouseNo;
            student.IsSponsored   = this.IsSponsored;
            student.IsHandicaped  = this.IsHandicaped;
            student.AdmissionYear = this.AdmissionYear;

            student.Campus       = this.Campus.MapToEntity <BusinessEntity.Lookup.CampusEntity>();
            student.Gender       = this.Gender.MapToEntity <BusinessEntity.Lookup.GenderEntity>();
            student.GradeSection = this.GradeSection.MapToEntity <BusinessEntity.Lookup.GradeSectionEntity>();
            student.Region       = this.Region.MapToEntity <BusinessEntity.Lookup.RegionEntity>();
            student.SubCity      = this.SubCity.MapToEntity <BusinessEntity.Lookup.SubCityEntity>();
            student.Woreda       = this.Woreda.MapToEntity <BusinessEntity.Lookup.WoredaEntity>();

            student.CreatedBy   = this.CreatedBy;
            student.CreatedDate = this.CreatedDate;
            student.UpdatedBy   = this.UpdatedBy;
            student.UpdatedDate = this.UpdatedDate;

            return(student as T);
        }
        public BusinessEntity.Result SaveStudent(BusinessEntity.Admission.StudentEntity Student)
        {
            BusinessEntity.Result result = new BusinessEntity.Result();
            try
            {
                SchoolInformationManagementSystemDBEntities e = new SchoolInformationManagementSystemDBEntities();
                e.tblStudents.Add(Student.MapToModel <DataAccessLogic.tblStudent>());
                e.SaveChanges();

                result.Message = "Saved Successfully.";
                result.Status  = true;
                return(result);
            }
            catch (Exception)
            {
                result.Message = "Failed to save";
                result.Status  = false;
                return(result);
            }
        }
        public StudentModel(BusinessEntity.Admission.StudentEntity student)
        {
            this.ID            = student.ID;
            this.Fullname      = student.Fullname;
            this.MotherName    = student.MotherName;
            this.BirthDate     = student.BirthDate;
            this.HouseNo       = student.HouseNo;
            this.IsSponsored   = student.IsSponsored;
            this.IsHandicaped  = student.IsHandicaped;
            this.AdmissionYear = student.AdmissionYear;

            this.Campus       = new CampusModel(student.Campus);
            this.Gender       = new GenderModel(student.Gender);
            this.GradeSection = new GradeSectionModel(student.GradeSection);
            this.Region       = new RegionModel(student.Region);
            this.SubCity      = new SubCityModel(student.SubCity);
            this.Woreda       = new WoredaModel(student.Woreda);

            this.CreatedBy   = student.CreatedBy;
            this.CreatedDate = student.CreatedDate;
            this.UpdatedBy   = student.UpdatedBy;
            this.UpdatedDate = student.UpdatedDate;
        }