public async Task <VendorUnitDto> UpdateVendorUnit(UpdateVendorUnitInput input) { var vendorUnit = await _vendorUnitRepository.GetAsync(input.VendorId); // update address Information if (!ReferenceEquals(input.Addresses, null)) { foreach (var address in input.Addresses) { if (address.AddressId != 0) { await _addressAppService.UpdateAddressUnit(address); } else { if (!string.IsNullOrEmpty(address.Line1) || !string.IsNullOrEmpty(address.Line2) || !string.IsNullOrEmpty(address.Line4) || !string.IsNullOrEmpty(address.Line4) || !string.IsNullOrEmpty(address.State) || !string.IsNullOrEmpty(address.Country) || !string.IsNullOrEmpty(address.Email) || !string.IsNullOrEmpty(address.Phone1) || !string.IsNullOrEmpty(address.ContactNumber)) { address.TypeofObjectId = TypeofObject.VendorUnit; address.ObjectId = input.VendorId; //AutoMapper.Mapper.CreateMap<UpdateAddressUnitInput, CreateAddressUnitInput>(); //var config = new MapperConfiguration(cfg => { // cfg.CreateMap<UpdateAddressUnitInput, CreateAddressUnitInput>(); //}); await _addressAppService.CreateAddressUnit( AutoMapper.Mapper.Map <UpdateAddressUnitInput, CreateAddressUnitInput>(address)); } } await CurrentUnitOfWork.SaveChangesAsync(); } } //Update vendorAlias Information if (input.VendorAlias != null) { foreach (var vendorAlias in input.VendorAlias) { if (!string.IsNullOrEmpty(vendorAlias.AliasName)) { VendorAliasUnit vendorAliasUnit = new VendorAliasUnit(); vendorAliasUnit.VendorId = vendorUnit.Id; vendorAliasUnit.AliasName = vendorAlias.AliasName; if (vendorAlias.VendorAliasId.Equals(0)) { await _vendorAliasUnitManager.CreateAsync(vendorAliasUnit); } else { vendorAliasUnit.Id = vendorAlias.VendorAliasId; await _vendorAliasUnitManager.UpdateAsync(vendorAliasUnit); } await CurrentUnitOfWork.SaveChangesAsync(); } } } #region Setting the values to be updated vendorUnit.LastName = input.LastName; vendorUnit.PayToName = input.PayToName; vendorUnit.VendorAccountInfo = input.VendorAccountInfo; vendorUnit.CreditLimit = input.CreditLimit; vendorUnit.PaymentTermsId = input.PaymentTermsId; vendorUnit.IsCorporation = input.IsCorporation; vendorUnit.IsIndependentContractor = input.IsIndependentContractor; vendorUnit.Isw9OnFile = input.Isw9OnFile; vendorUnit.TypeofVendorId = input.TypeofvendorId; vendorUnit.EDDContractStartDate = input.EDDContractStartDate; vendorUnit.EDDContractStopDate = input.EDDContractStopDate; vendorUnit.WorkRegion = input.WorkRegion; vendorUnit.ACHBankName = input.ACHBankName; vendorUnit.ACHWireFromBankName = input.ACHWireFromBankName; vendorUnit.ACHWireFromSwiftCode = input.ACHWireFromSwiftCode; vendorUnit.ACHWireFromAccountNumber = input.ACHWireFromAccountNumber; vendorUnit.ACHWireToSwiftCode = input.ACHWireToSwiftCode; vendorUnit.ACHWireToAccountNumber = input.ACHWireToAccountNumber; vendorUnit.ACHWireToIBAN = input.ACHWireToIBAN; vendorUnit.OrganizationUnitId = input.OrganizationUnitId; vendorUnit.VendorNumber = input.VendorNumber; vendorUnit.FedralTaxId = input.FedralTaxId; vendorUnit.FirstName = input.FirstName; vendorUnit.DbaName = input.DbaName; vendorUnit.SSNTaxId = input.SSNTaxId; vendorUnit.TypeofPaymentMethodId = input.TypeofPaymentMethodId; vendorUnit.TypeofCurrencyId = input.TypeofCurrencyId; vendorUnit.Is1099 = input.Is1099; vendorUnit.ACHRoutingNumber = input.ACHRoutingNumber; vendorUnit.Typeof1099BoxId = input.Typeof1099BoxId; vendorUnit.EDDConctractAmount = input.EDDConctractAmount; vendorUnit.IsEDDContractOnGoing = input.IsEDDContractOnGoing; vendorUnit.ACHAccountNumber = input.ACHAccountNumber; vendorUnit.ACHWireFromBankAddress = input.ACHWireFromBankAddress; vendorUnit.ACHWireToBankName = input.ACHWireToBankName; vendorUnit.ACHWireToBeneficiary = input.ACHWireToBeneficiary; vendorUnit.IsApproved = input.IsApproved; vendorUnit.OrganizationUnitId = input.OrganizationUnitId; vendorUnit.IsActive = input.IsActive; vendorUnit.TypeofTaxId = input.TypeofTaxId; vendorUnit.BillingAccount = input.BillingAccount; vendorUnit.GLAccountId = input.GLAccountId; vendorUnit.AccountId = input.AccountId; vendorUnit.Notes = input.Notes; vendorUnit.JobId = input.JobId; vendorUnit.TaxCreditId = input.TaxCreditId; #endregion await _vendorUnitManager.UpdateAsync(vendorUnit); await CurrentUnitOfWork.SaveChangesAsync(); _unitOfWorkManager.Current.Completed += (sender, args) => { /*Do Something when the Chart of Vendor is Added*/ }; EventBus.Register <EntityChangedEventData <CoaUnit> >( eventData => { // http://www.aspnetboilerplate.com/Pages/Documents/EventBus-Domain-Events#DocTriggerEvents //Do something when Vendor is added }); var VendorUnitDto = vendorUnit.MapTo <VendorUnitDto>(); VendorUnitDto.VendorId = vendorUnit.Id; return(VendorUnitDto); }
public async Task <EmployeeUnitDto> UpdateEmployeeUnit(UpdateEmployeeUnitInput input) { var employeeUnit = await _employeeUnitRepository.GetAsync(input.EmployeeId); #region Setting the values to be updated employeeUnit.LastName = input.LastName; employeeUnit.FirstName = input.FirstName; employeeUnit.EmployeeRegion = input.EmployeeRegion; employeeUnit.FederalTaxId = input.FederalTaxId; employeeUnit.Is1099 = input.Is1099; employeeUnit.IsActive = input.IsActive; employeeUnit.IsApproved = input.IsApproved; employeeUnit.IsArtDirector = input.IsArtDirector; employeeUnit.IsCorporation = input.IsCorporation; employeeUnit.IsDirPhoto = input.IsDirPhoto; employeeUnit.IsDirector = input.IsDirector; employeeUnit.IsEditor = input.IsEditor; employeeUnit.IsIndependantContractor = input.IsIndependantContractor; employeeUnit.IsProducer = input.IsProducer; employeeUnit.SSNTaxId = input.SSNTaxId; employeeUnit.OrganizationUnitId = input.OrganizationUnitId; employeeUnit.SSNTaxId = input.SSNTaxId; employeeUnit.IsSetDesigner = input.IsSetDesigner; #endregion await _employeeUnitManager.UpdateAsync(employeeUnit); await CurrentUnitOfWork.SaveChangesAsync(); foreach (var address in input.Addresses) { if (address.AddressId != 0) { await _addressAppService.UpdateAddressUnit(address); } else { if (!string.IsNullOrEmpty(address.Line1) || !string.IsNullOrEmpty(address.Line2) || !string.IsNullOrEmpty(address.Line4) || !string.IsNullOrEmpty(address.Line4) || !string.IsNullOrEmpty(address.State) || !string.IsNullOrEmpty(address.Country) || !string.IsNullOrEmpty(address.Email) || !string.IsNullOrEmpty(address.Phone1) || !string.IsNullOrEmpty(address.Website)) { address.TypeofObjectId = TypeofObject.EmployeeUnit; address.ObjectId = input.EmployeeId; await _addressAppService.CreateAddressUnit( AutoMapper.Mapper.Map <UpdateAddressUnitInput, CreateAddressUnitInput>(address)); } } await CurrentUnitOfWork.SaveChangesAsync(); } _unitOfWorkManager.Current.Completed += (sender, args) => { /*Do Something when the Chart of employee is Added*/ }; return(employeeUnit.MapTo <EmployeeUnitDto>()); }