public int Update(EmployeesQualifications EmployeeQualification) { try { using (var db = new HCMEntities()) { EmployeesQualifications EmployeeQualificationObj = db.EmployeesQualifications.SingleOrDefault(x => x.EmployeeQualificationID.Equals(EmployeeQualification.EmployeeQualificationID)); EmployeeQualificationObj.QualificationDegreeID = EmployeeQualification.QualificationDegreeID; EmployeeQualificationObj.QualificationID = EmployeeQualification.QualificationID; EmployeeQualificationObj.GeneralSpecializationID = EmployeeQualification.GeneralSpecializationID; EmployeeQualificationObj.ExactSpecializationID = EmployeeQualification.ExactSpecializationID; EmployeeQualificationObj.UniSchName = EmployeeQualification.UniSchName; EmployeeQualificationObj.Department = EmployeeQualification.Department; EmployeeQualificationObj.FullGPA = EmployeeQualification.FullGPA; EmployeeQualificationObj.GPA = EmployeeQualification.GPA; EmployeeQualificationObj.StudyPlace = EmployeeQualification.StudyPlace; EmployeeQualificationObj.GraduationDate = EmployeeQualification.GraduationDate; EmployeeQualificationObj.GraduationYear = EmployeeQualification.GraduationYear; //EmployeeQualificationObj.Percentage = EmployeeQualification.Percentage; EmployeeQualificationObj.QualificationTypeID = EmployeeQualification.QualificationTypeID; EmployeeQualificationObj.LastUpdatedDate = EmployeeQualification.LastUpdatedDate; EmployeeQualificationObj.LastUpdatedBy = EmployeeQualification.LastUpdatedBy; return(db.SaveChanges()); } } catch { throw; } }
public int Delete(int EmployeeQualificationID, int UserIdentity) { try { using (var db = new HCMEntities()) { EmployeesQualifications EmployeeQualificationObj = db.EmployeesQualifications.FirstOrDefault(x => x.EmployeeQualificationID.Equals(EmployeeQualificationID)); db.EmployeesQualifications.Remove(EmployeeQualificationObj); return(db.SaveChanges(UserIdentity)); } } catch { throw; } }
public int Insert(EmployeesQualifications EmployeeQualification) { try { using (var db = new HCMEntities()) { db.EmployeesQualifications.Add(EmployeeQualification); db.SaveChanges(); return(EmployeeQualification.EmployeeQualificationID); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } }