protected virtual async Task UpdateEditionAsync(CreateOrUpdateEditionDto input) { EditionManager editionManager = this._editionManager; int? id = input.Edition.Id; Edition byIdAsync = await editionManager.GetByIdAsync(id.Value); byIdAsync.DisplayName = input.Edition.DisplayName; await this.SetFeatureValues(byIdAsync, input.FeatureValues); }
protected virtual async Task UpdateEditionAsync(CreateOrUpdateEditionDto input) { Debug.Assert(input.Edition.Id != null, "input.Edition.Id should be set."); var edition = await _editionManager.GetByIdAsync(input.Edition.Id.Value); edition.DisplayName = input.Edition.DisplayName; await SetFeatureValues(edition, input.FeatureValues); }
protected virtual async Task CreateEditionAsync(CreateOrUpdateEditionDto input) { var edition = new Edition(input.Edition.DisplayName); await _editionManager.CreateAsync(edition); await CurrentUnitOfWork.SaveChangesAsync(); //It's done to get Id of the edition. await SetFeatureValues(edition, input.FeatureValues); }
protected virtual async Task CreateEditionAsync(CreateOrUpdateEditionDto input) { Edition edition = new Edition(input.Edition.DisplayName); await this._editionManager.CreateAsync(edition); await this.CurrentUnitOfWork.SaveChangesAsync(); await this.SetFeatureValues(edition, input.FeatureValues); }
public async Task CreateOrUpdateEdition(CreateOrUpdateEditionDto input) { if (!input.Edition.Id.HasValue) { await CreateEditionAsync(input); } else { await UpdateEditionAsync(input); } }
protected virtual async Task CreateEditionAsync(CreateOrUpdateEditionDto input) { var edition = ObjectMapper.Map <SubscribableEdition>(input.Edition); if (edition.ExpiringEditionId.HasValue) { var expiringEdition = ObjectMapper.Map <SubscribableEdition>(await _editionManager.GetByIdAsync(edition.ExpiringEditionId.Value)); if (!expiringEdition.IsFree) { throw new UserFriendlyException(L("ExpiringEditionMustBeAFreeEdition")); } } await _editionManager.CreateAsync(edition); await CurrentUnitOfWork.SaveChangesAsync(); //It's done to get Id of the edition. await SetFeatureValues(edition, input.FeatureValues); }
protected virtual async Task UpdateEditionAsync(CreateOrUpdateEditionDto input) { if (input.Edition.Id != null) { var edition = await _editionManager.GetByIdAsync(input.Edition.Id.Value); var existingSubscribableEdition = ObjectMapper.Map <SubscribableEdition>(edition); var updatingSubscribableEdition = ObjectMapper.Map <SubscribableEdition>(input.Edition); if (existingSubscribableEdition.IsFree && !updatingSubscribableEdition.IsFree && await _subscribableEditionRepository.CountAsync(e => e.ExpiringEditionId == existingSubscribableEdition.Id) > 0) { throw new UserFriendlyException(L("ThisEditionIsUsedAsAnExpiringEdition")); } ObjectMapper.Map(input.Edition, edition); await SetFeatureValues(edition, input.FeatureValues); } }