コード例 #1
0
ファイル: BranchAppService.cs プロジェクト: BugBear96/VOU
        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));
        }
コード例 #2
0
 public Task <BranchWithVoucherPlatform> CreateBranchWithVoucherPlatformAsync(BranchWithVoucherPlatform platform)
 {
     return(_voucherPlatformRepository.InsertAsync(platform));
 }