Exemplo n.º 1
0
 public int Delete(int PromotionJobCategoryID, int UserIdentity)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             PromotionsJobsCategories PromotionJobCategory = db.PromotionsJobsCategories.SingleOrDefault(x => x.PromotionJobCategoryID.Equals(PromotionJobCategoryID));
             db.PromotionsJobsCategories.Remove(PromotionJobCategory);
             return(db.SaveChanges(UserIdentity));
         }
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 2
0
 public int Insert(PromotionsJobsCategories PromotionJobCategory)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             db.PromotionsJobsCategories.Add(PromotionJobCategory);
             db.SaveChanges();
             return(PromotionJobCategory.PromotionJobCategoryID);
         }
     }
     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;
     }
 }