public int Delete(int InsteadDeportationID, int UserIdentity) { try { using (var db = new HCMEntities()) { InsteadDeportations InsteadDeportationObj = db.InsteadDeportations.SingleOrDefault(x => x.InsteadDeportationID.Equals(InsteadDeportationID)); db.InsteadDeportations.Remove(InsteadDeportationObj); return(db.SaveChanges(UserIdentity)); } } catch { throw; } }
public int Update(InsteadDeportations InsteadDeportation) { try { using (var db = new HCMEntities()) { InsteadDeportations InsteadDeportationObj = db.InsteadDeportations.SingleOrDefault(x => x.InsteadDeportationID.Equals(InsteadDeportation.InsteadDeportationID)); InsteadDeportationObj.EmployeeCareerHistoryID = InsteadDeportation.EmployeeCareerHistoryID; InsteadDeportationObj.DeportationDate = InsteadDeportation.DeportationDate; InsteadDeportationObj.Amount = InsteadDeportation.Amount; InsteadDeportationObj.Note = InsteadDeportation.Note; InsteadDeportationObj.LastUpdatedDate = InsteadDeportation.LastUpdatedDate; InsteadDeportationObj.LastUpdatedBy = InsteadDeportation.LastUpdatedBy; return(db.SaveChanges()); } } catch { throw; } }
public int Insert(InsteadDeportations InsteadDeportation) { try { using (var db = new HCMEntities()) { db.InsteadDeportations.Add(InsteadDeportation); db.SaveChanges(); return(InsteadDeportation.InsteadDeportationID); } } 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; } }