public coreModel.DynamicContentPlace CreatePlace(coreModel.DynamicContentPlace place) { var entity = place.ToDataModel(); coreModel.DynamicContentPlace retVal = null; using (var repository = _repositoryFactory()) { repository.Add(entity); CommitChanges(repository); } retVal = GetPlaceById(entity.Id); return(retVal); }
public void UpdatePlace(coreModel.DynamicContentPlace place) { using (var repository = _repositoryFactory()) using (var changeTracker = GetChangeTracker(repository)) { var sourceEntity = place.ToDataModel(); var targetEntity = repository.GetContentPlaceById(place.Id); if (targetEntity == null) { repository.Add(sourceEntity); } else { changeTracker.Attach(targetEntity); sourceEntity.Patch(targetEntity); } CommitChanges(repository); } }