private static void CheckError(CreateOrUpdateAdvertAccountInput input) { if (input.StoreId == 0) { throw new UserFriendlyException("请选择店铺"); } }
protected virtual async Task <AdvertAccount> UpdateAccountAsync(CreateOrUpdateAdvertAccountInput input) { var account = ObjectMapper.Map <AdvertAccount>(input); await _advertAccountManager.UpdateAsync(account); return(account); }
/// <summary> /// 创建或更新广告账户 /// </summary> /// <param name="input"></param> /// <returns></returns> public virtual async Task <EntityDto <long> > CreateOrUpdateAccount(CreateOrUpdateAdvertAccountInput input) { CheckError(input); AdvertAccount account; if (input.Id.HasValue && input.Id.Value > 0) { account = await UpdateAccountAsync(input); } else { account = await CreateAccountAsync(input); } await CurrentUnitOfWork.SaveChangesAsync(); return(new EntityDto <long> { Id = account.Id }); }