public async Task <EntityDto> CreateOrUpdateVoucherPlatform(BranchWithVoucherPlatformEditDto input) { var isEdit = input.Id > 0; BranchWithVoucherPlatform platform; Location location; VoucherPlatform voucherPlatform; if (isEdit) { platform = await _locationManager.FindVoucherPlatformAsync(input.Id); if (platform == null) { throw new UserFriendlyException(L("InvalidVoucherPlatform")); } } else { location = await _locationManager.FindLocationAsync(input.LocationId); voucherPlatform = await _voucherPlatformManager.FindAsync(input.VoucherPlatformId); platform = new BranchWithVoucherPlatform(location, voucherPlatform); } //location.VoucherPlatforms = new List<BranchWithVoucherPlatform>(); platform.UpdateTime(input.Start, input.End); if (!isEdit) { await _locationManager.CreateBranchWithVoucherPlatformAsync(platform); } await CurrentUnitOfWork.SaveChangesAsync(); return(new EntityDto(platform.Id)); }