public int Delete(int JobCategoryID, int UserIdentity) { try { using (var db = new HCMEntities()) { JobsCategories JobCategory = db.JobsCategories.SingleOrDefault(x => x.JobCategoryID.Equals(JobCategoryID)); db.JobsCategories.Remove(JobCategory); return(db.SaveChanges(UserIdentity)); } } catch { throw; } }
public int Insert(JobsCategories JobCategory) { try { using (var db = new HCMEntities()) { db.JobsCategories.Add(JobCategory); db.SaveChanges(); return(JobCategory.JobCategoryID); } } 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; } }
public int Update(JobsCategories JobCategory) { try { using (var db = new HCMEntities()) { JobsCategories JobCategoryObj = db.JobsCategories.SingleOrDefault(x => x.JobCategoryID.Equals(JobCategory.JobCategoryID)); JobCategoryObj.JobCategoryID = JobCategory.JobCategoryID; JobCategoryObj.JobCategoryName = JobCategory.JobCategoryName; JobCategoryObj.JobGroupID = JobCategory.JobGroupID; JobCategoryObj.LastUpdatedDate = DateTime.Now; JobCategoryObj.LastUpdatedBy = JobCategory.LastUpdatedBy; JobCategoryObj.MinGeneralSpecializationID = JobCategory.MinGeneralSpecializationID; JobCategoryObj.MinQualificationDegreeID = JobCategory.MinQualificationDegreeID; JobCategoryObj.MinQualificationID = JobCategory.MinQualificationID; JobCategoryObj.JobCategoryNo = JobCategory.JobCategoryNo; return(db.SaveChanges()); } } catch { throw; } }