예제 #1
0
 public int Delete(Transfers Transfer, int UserIdentity)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             Transfers TransferObj = db.Transfers.FirstOrDefault(x => x.TransferID.Equals(Transfer.TransferID));
             db.Transfers.Remove(TransferObj);
             return(db.SaveChanges(UserIdentity));
         }
     }
     catch
     {
         throw;
     }
 }
예제 #2
0
 public int UpdateIsProcess(Transfers Transfer)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             Transfers TransferObj = db.Transfers.FirstOrDefault(x => x.TransferID.Equals(Transfer.TransferID));
             TransferObj.IsProcessed     = Transfer.IsProcessed;
             TransferObj.LastUpdatedDate = Transfer.LastUpdatedDate;
             TransferObj.LastUpdatedBy   = Transfer.LastUpdatedBy;
             return(db.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #3
0
 public int Insert(Transfers Transfer)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             db.Transfers.Add(Transfer);
             db.SaveChanges();
             return(Transfer.TransferID);
         }
     }
     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;
     }
 }