public int Delete(int EmployeeAllowanceID, int UserIdentity)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             EmployeesAllowances EmployeeAllowanceObj = db.EmployeesAllowances.SingleOrDefault(x => x.EmployeeAllowanceID.Equals(EmployeeAllowanceID));
             db.EmployeesAllowances.Remove(EmployeeAllowanceObj);
             return(db.SaveChanges(UserIdentity));
         }
     }
     catch
     {
         throw;
     }
 }
 public int Update(EmployeesAllowances EmployeeAllowance)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             EmployeesAllowances EmployeeAllowanceObj = db.EmployeesAllowances.SingleOrDefault(x => x.EmployeeAllowanceID.Equals(EmployeeAllowance.EmployeeAllowanceID));
             EmployeeAllowanceObj.EmployeeCareerHistoryID = EmployeeAllowance.EmployeeCareerHistoryID;
             EmployeeAllowanceObj.AllowanceID             = EmployeeAllowance.AllowanceID;
             EmployeeAllowanceObj.AllowanceStartDate      = EmployeeAllowance.AllowanceStartDate;
             EmployeeAllowanceObj.IsActive        = EmployeeAllowance.IsActive;
             EmployeeAllowanceObj.LastUpdatedDate = EmployeeAllowance.LastUpdatedDate;
             EmployeeAllowanceObj.LastUpdatedBy   = EmployeeAllowance.LastUpdatedBy;
             return(db.SaveChanges());
         }
     }
     catch
     {
         throw;
     }
 }
 public int Insert(EmployeesAllowances EmployeeAllowance)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             db.EmployeesAllowances.Add(EmployeeAllowance);
             db.SaveChanges();
             return(EmployeeAllowance.EmployeeAllowanceID);
         }
     }
     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;
     }
 }