/// <summary> /// Updates an existing item in the database. /// </summary> /// <param name="entity"> /// The entity. /// </param> protected override void PersistUpdatedItem(IShipCountry entity) { ((Entity)entity).UpdatingEntity(); var factory = new ShipCountryFactory(_storeSettingService); var dto = factory.BuildDto(entity); Database.Update(dto); entity.ResetDirtyProperties(); }
/// <summary> /// Saves a new item to the database. /// </summary> /// <param name="entity"> /// The entity. /// </param> protected override void PersistNewItem(IShipCountry entity) { // TODO : revisit how this constraint is implemented // Assert that a ShipCountry for a given WarehouseCatalog does not already exist with this country code if (Exists(entity.CatalogKey, entity.CountryCode)) { throw new ConstraintException("A merchShipCountry record already exists with the CatalogKey and CountryCode"); } ((Entity)entity).AddingEntity(); var factory = new ShipCountryFactory(_storeSettingService); var dto = factory.BuildDto(entity); Database.Insert(dto); entity.Key = dto.Key; entity.ResetDirtyProperties(); }