Example #1
0
 public int Delete(int JobGeneralGroupID, int UserIdentity)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             JobsGeneralGroups JobGeneralGroup = db.JobsGeneralGroups.SingleOrDefault(x => x.JobGeneralGroupID.Equals(JobGeneralGroupID));
             db.JobsGeneralGroups.Remove(JobGeneralGroup);
             return(db.SaveChanges(UserIdentity));
         }
     }
     catch
     {
         throw;
     }
 }
Example #2
0
 public int Update(JobsGeneralGroups JobGeneralGroup)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             JobsGeneralGroups JobGeneralGroupObj = db.JobsGeneralGroups.SingleOrDefault(x => x.JobGeneralGroupID.Equals(JobGeneralGroup.JobGeneralGroupID));
             JobGeneralGroupObj.JobGeneralGroupID   = JobGeneralGroup.JobGeneralGroupID;
             JobGeneralGroupObj.JobGeneralGroupName = JobGeneralGroup.JobGeneralGroupName;
             JobGeneralGroupObj.LastUpdatedDate     = DateTime.Now;
             JobGeneralGroupObj.LastUpdatedBy       = JobGeneralGroup.LastUpdatedBy;
             return(db.SaveChanges());
         }
     }
     catch
     {
         throw;
     }
 }
Example #3
0
 public int Insert(JobsGeneralGroups JobGeneralGroup)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             db.JobsGeneralGroups.Add(JobGeneralGroup);
             db.SaveChanges();
             return(JobGeneralGroup.JobGeneralGroupID);
         }
     }
     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;
     }
 }