Ejemplo n.º 1
0
 public int Insert(HolidaysSettings HolidaySetting)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             db.HolidaysSettings.Add(HolidaySetting);
             db.SaveChanges();
             return(HolidaySetting.HolidaySettingID);
         }
     }
     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;
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 2
0
 public int Update(HolidaysSettings HolidaySetting)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             HolidaysSettings HolidaySettingObj = db.HolidaysSettings.SingleOrDefault(x => x.HolidaySettingID.Equals(HolidaySetting.HolidaySettingID));
             HolidaySettingObj.HolidaySettingEndDate   = HolidaySetting.HolidaySettingEndDate;
             HolidaySettingObj.HolidaySettingStartDate = HolidaySetting.HolidaySettingStartDate;
             HolidaySettingObj.MaturityYearID          = HolidaySetting.MaturityYearID;
             HolidaySettingObj.HolidayTypeID           = HolidaySetting.HolidayTypeID;
             HolidaySettingObj.LastUpdatedDate         = DateTime.Now;
             HolidaySettingObj.LastUpdatedBy           = HolidaySetting.LastUpdatedBy;
             return(db.SaveChanges());
         }
     }
     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;
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 3
0
 public int Delete(int HolidaySettingID, int UserIdentity)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             HolidaysSettings HolidaySettingObj = db.HolidaysSettings.SingleOrDefault(x => x.HolidaySettingID.Equals(HolidaySettingID));
             db.HolidaysSettings.Remove(HolidaySettingObj);
             return(db.SaveChanges(UserIdentity));
         }
     }
     catch
     {
         throw;
     }
 }