public void UpdateTheftMethod(DB_TheftMethod theftMethod) { if (theftMethod == null) { throw new ArgumentNullException(nameof(theftMethod)); } if (theftMethod.ID < 1) { _db.DB_TheftMethods.InsertOnSubmit(theftMethod); } _db.SubmitChanges(); }
public void UpdateTheftMethod(TheftMethod theftMethod) { if (theftMethod == null) { throw new ArgumentNullException(nameof(theftMethod)); } if (!theftMethod.IsValid()) { throw new ArgumentException("theftMethod is invalid!"); } lock (theftMethod) { var isNew = false; DB_TheftMethod dbTheftMethod; if (theftMethod.IsPersisted) { dbTheftMethod = Controller.Instance.Repository.GetTheftMethod(theftMethod.Id); } else { dbTheftMethod = new DB_TheftMethod(); isNew = true; } dbTheftMethod.Name = theftMethod.Name; Controller.Instance.Repository.UpdateTheftMethod(dbTheftMethod); if (!isNew) { return; } theftMethod.Id = dbTheftMethod.ID; theftMethod.IsPersisted = true; Controller.Instance.CacheManager.Remove("TheftMethods"); } }