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; } }
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; } }
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; } }