Beispiel #1
0
 public int Delete(OverTimes OverTime, int UserIdentity)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             OverTimes OverTimeObj = db.OverTimes.SingleOrDefault(x => x.OverTimeID.Equals(OverTime.OverTimeID));
             OverTimeObj.OverTimesDetails.ToList().ForEach(d => db.OverTimesDetails.Remove(d));
             db.OverTimes.Remove(OverTimeObj);
             return(db.SaveChanges(UserIdentity));
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #2
0
 public int Approve(OverTimes OverTime)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             OverTimes OverTimeObj = db.OverTimes.SingleOrDefault(x => x.OverTimeID.Equals(OverTime.OverTimeID));
             OverTimeObj.ApprovedBy    = OverTime.ApprovedBy;
             OverTimeObj.ApprovedDate  = OverTime.ApprovedDate;
             OverTimeObj.IsApproved    = OverTime.IsApproved;
             OverTimeObj.LastUpdatedBy = OverTime.LastUpdatedBy;
             return(db.SaveChanges());
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #3
0
 public int Update(OverTimes OverTime)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             OverTimes OverTimeObj = db.OverTimes.SingleOrDefault(x => x.OverTimeID.Equals(OverTime.OverTimeID));
             OverTimeObj.OverTimeID       = OverTime.OverTimeID;
             OverTimeObj.Tasks            = OverTime.Tasks;
             OverTimeObj.WeekWorkHoursAvg = OverTime.WeekWorkHoursAvg;
             OverTimeObj.FridayHoursAvg   = OverTime.FridayHoursAvg;
             OverTimeObj.SaturdayHoursAvg = OverTime.SaturdayHoursAvg;
             OverTimeObj.LastUpdatedDate  = OverTime.LastUpdatedDate;
             OverTimeObj.LastUpdatedBy    = OverTime.LastUpdatedBy;
             return(db.SaveChanges());
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #4
0
 public int Insert(OverTimes OverTime)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             db.OverTimes.Add(OverTime);
             db.SaveChanges();
             return(OverTime.OverTimeID);
         }
     }
     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;
     }
 }