示例#1
0
        /// <summary>
        /// Validating the VendorAliasName
        /// </summary>
        /// <param name="vendorUnit"></param>
        /// <returns></returns>
        protected virtual async Task ValidateVendorAliasUnitAsync(VendorAliasUnit vendorAlias)
        {
            //Validating if Duplicate VendorAliasName exists
            if (VendorAliasUnitRepository != null)
            {
                var vendorsAliasUnit = (await VendorAliasUnitRepository.GetAllListAsync(p => p.AliasName == vendorAlias.AliasName && p.VendorId == vendorAlias.VendorId));

                if (vendorAlias.Id == 0)
                {
                    if (vendorsAliasUnit.Count > 0)
                    {
                        throw new UserFriendlyException(L("Duplicate Name", vendorAlias.AliasName));
                    }
                }
                else
                {
                    if (vendorsAliasUnit.FirstOrDefault(p => p.Id != vendorAlias.Id && p.AliasName == vendorAlias.AliasName && p.VendorId == vendorAlias.VendorId) != null)
                    {
                        throw new UserFriendlyException(L("Duplicate Name", vendorAlias.AliasName));
                    }
                }
            }
        }
示例#2
0
        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);
        }
示例#3
0
        /// <summary>
        /// Updating VendorAliasName Details
        /// </summary>
        /// <param name="vendorAlias"></param>
        /// <returns></returns>
        public virtual async Task UpdateAsync(VendorAliasUnit vendorAlias)
        {
            await ValidateVendorAliasUnitAsync(vendorAlias);

            await VendorAliasUnitRepository.UpdateAsync(vendorAlias);
        }