public async Task <int> Update(int id, GarmentShippingCreditAdviceViewModel viewModel)
        {
            viewModel.buyer = viewModel.buyer ?? new Buyer();
            viewModel.bank  = viewModel.bank ?? new BankAccount();
            GarmentShippingCreditAdviceModel model = new GarmentShippingCreditAdviceModel(viewModel.packingListId, viewModel.invoiceId, viewModel.invoiceNo, viewModel.date.GetValueOrDefault(), viewModel.amount, viewModel.amountToBePaid, viewModel.paymentTerm, viewModel.receiptNo, viewModel.lcNo, viewModel.valas, viewModel.lcType, viewModel.inkaso, viewModel.disconto, viewModel.srNo, viewModel.negoDate.GetValueOrDefault(), viewModel.paymentDate.GetValueOrDefault(), viewModel.condition, viewModel.bankComission, viewModel.discrepancyFee, viewModel.nettNego, viewModel.btbCADate.GetValueOrDefault(), viewModel.btbAmount, viewModel.btbRatio, viewModel.btbRate, viewModel.btbTransfer, viewModel.btbMaterial, viewModel.billDays, viewModel.billAmount, viewModel.billCA, viewModel.buyer.Id, viewModel.buyer.Name, viewModel.buyer.Address, viewModel.bank.id, viewModel.bank.accountName, viewModel.bank.bankAddress, viewModel.creditInterest, viewModel.bankCharges, viewModel.otherCharge, viewModel.documentPresente.GetValueOrDefault(), viewModel.cargoPolicyNo, viewModel.cargoPolicyDate.GetValueOrDefault(), viewModel.cargoPolicyValue, viewModel.accountsReceivablePolicyNo, viewModel.accountsReceivablePolicyDate.GetValueOrDefault(), viewModel.accountsReceivablePolicyValue, viewModel.documentSendDate.GetValueOrDefault(), viewModel.remark);

            return(await _repository.UpdateAsync(id, model));
        }
        private GarmentShippingCreditAdviceViewModel MapToViewModel(GarmentShippingCreditAdviceModel model)
        {
            GarmentShippingCreditAdviceViewModel viewModel = new GarmentShippingCreditAdviceViewModel
            {
                Active            = model.Active,
                Id                = model.Id,
                CreatedAgent      = model.CreatedAgent,
                CreatedBy         = model.CreatedBy,
                CreatedUtc        = model.CreatedUtc,
                DeletedAgent      = model.DeletedAgent,
                DeletedBy         = model.DeletedBy,
                DeletedUtc        = model.DeletedUtc,
                IsDeleted         = model.IsDeleted,
                LastModifiedAgent = model.LastModifiedAgent,
                LastModifiedBy    = model.LastModifiedBy,
                LastModifiedUtc   = model.LastModifiedUtc,
                receiptNo         = model.ReceiptNo,
                packingListId     = model.PackingListId,
                invoiceId         = model.InvoiceId,
                invoiceNo         = model.InvoiceNo,
                paymentTerm       = model.PaymentTerm,

                lcNo           = model.LCNo,
                date           = model.Date,
                amount         = model.Amount,
                amountToBePaid = model.AmountToBePaid,

                valas          = model.Valas,
                lcType         = model.LCType,
                inkaso         = model.Inkaso,
                disconto       = model.Disconto,
                srNo           = model.SRNo,
                negoDate       = model.NegoDate,
                paymentDate    = model.PaymentDate,
                condition      = model.Condition,
                bankComission  = model.BankComission,
                discrepancyFee = model.DiscrepancyFee,
                nettNego       = model.NettNego,

                btbCADate   = model.BTBCADate,
                btbAmount   = model.BTBAmount,
                btbRatio    = model.BTBRatio,
                btbRate     = model.BTBRate,
                btbTransfer = model.BTBTransfer,
                btbMaterial = model.BTBMaterial,

                billDays   = model.BillDays,
                billAmount = model.BillAmount,
                billCA     = model.BillCA,
                buyer      = new Buyer
                {
                    Id      = model.BuyerId,
                    Name    = model.BuyerName,
                    Address = model.BuyerAddress
                },
                bank = new BankAccount
                {
                    id          = model.BankAccountId,
                    accountName = model.BankAccountName,
                    bankAddress = model.BankAddress
                },
                creditInterest                = model.CreditInterest,
                bankCharges                   = model.BankCharges,
                otherCharge                   = model.OtherCharge,
                documentPresente              = model.DocumentPresente,
                cargoPolicyNo                 = model.CargoPolicyNo,
                cargoPolicyDate               = model.CargoPolicyDate,
                cargoPolicyValue              = model.CargoPolicyValue,
                accountsReceivablePolicyNo    = model.AccountsReceivablePolicyNo,
                accountsReceivablePolicyDate  = model.AccountsReceivablePolicyDate,
                accountsReceivablePolicyValue = model.AccountsReceivablePolicyValue,
                documentSendDate              = model.DocumentSendDate,
                remark = model.Remark
            };

            return(viewModel);
        }