public async Task <VendorViewModel> CreateVendorAsync(VendorViewModel vendorViewModel) { var vendor = _mapper.Map <Vendor>(vendorViewModel); var pointOfSales = _mapper.Map <PointOfSale[]>(vendorViewModel.PointOfSales); var resultPointOfSales = await _pointOfSaleService.GetPointOfSalesAndCreateIfNotExistAsync(pointOfSales); vendor.PointOfSales = resultPointOfSales; await _vendorRepository.CreateAsync(vendor); var createVendorViewModel = _mapper.Map <VendorViewModel>(vendor); createVendorViewModel.PointOfSales = _mapper.Map <PointOfSaleViewModel[]>(resultPointOfSales); return(createVendorViewModel); }
public async Task CreateAsync(VendorDto vendor) { vendor.Id = vendor.Id == Guid.Empty ? Guid.NewGuid() : vendor.Id; await _vendorRepository.CreateAsync(_mapper.Map <Vendor>(vendor)); await _historyService.CreateAsync(UserAction.Add, "Created vendor " + vendor.Name); await _searchService.CreateAsync(vendor); await _notificationService.CreateVendorNotificationsAsync(vendor.Id); if (AnyDiscounts(vendor.Discounts)) { InitVendorInfoInDiscounts(vendor); var discounts = GetDiscountsFromDto(vendor); await _discountService.CreateManyAsync(discounts); } }