public async Task <int> Create(GarmentLetterOfCreditViewModel viewModel)
        {
            viewModel.Applicant = viewModel.Applicant ?? new Buyer();
            viewModel.Uom       = viewModel.Uom ?? new UnitOfMeasurement();
            GarmentShippingLetterOfCreditModel model = new GarmentShippingLetterOfCreditModel(viewModel.DocumentCreditNo, viewModel.Date.GetValueOrDefault(), viewModel.IssuedBank, viewModel.Applicant.Id, viewModel.Applicant.Code, viewModel.Applicant.Name, viewModel.ExpireDate.GetValueOrDefault(), viewModel.ExpirePlace, viewModel.LatestShipment.GetValueOrDefault(), viewModel.LCCondition, viewModel.Quantity, viewModel.Uom.Id.GetValueOrDefault(), viewModel.Uom.Unit, viewModel.TotalAmount);

            return(await _repository.InsertAsync(model));
        }
        private GarmentLetterOfCreditViewModel MapToViewModel(GarmentShippingLetterOfCreditModel model)
        {
            GarmentLetterOfCreditViewModel viewModel = new GarmentLetterOfCreditViewModel
            {
                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,


                Uom = new UnitOfMeasurement
                {
                    Id   = model.UomId,
                    Unit = model.UomUnit,
                },
                Applicant = new Buyer
                {
                    Id   = model.ApplicantId,
                    Code = model.ApplicantCode,
                    Name = model.ApplicantName,
                },
                TotalAmount      = model.TotalAmount,
                Date             = model.Date,
                DocumentCreditNo = model.DocumentCreditNo,
                ExpireDate       = model.ExpireDate,
                ExpirePlace      = model.ExpirePlace,
                IssuedBank       = model.IssuedBank,
                LatestShipment   = model.LatestShipment,
                LCCondition      = model.LCCondition,
                Quantity         = model.Quantity
            };

            return(viewModel);
        }