public Task <int> MappingData(VbNonPORequestViewModel viewModel)
        {
            var result     = new List <VbRequestDetailModel>();
            var myProperty = viewModel.GetType().GetProperties();

            int value = int.Parse(dbSet.OrderByDescending(p => p.Id)
                                  .Select(r => r.Id)
                                  .First().ToString());

            foreach (var prop in myProperty.Where(x => x.PropertyType == typeof(bool)))
            {
                if ((bool)prop.GetValue(viewModel))
                {
                    var item = new VbRequestDetailModel()
                    {
                        VBId = value, UnitName = prop.Name
                    };
                    if (prop.Name.ToUpper() == "OTHERS")
                    {
                        item.DetailOthers = viewModel.DetailOthers;
                    }

                    EntityExtension.FlagForCreate(item, _identityService.Username, UserAgent);
                    _dbContext.VbRequestsDetails.Add(item);
                    //_dbContext.SaveChangesAsync();
                }
            }

            return(_dbContext.SaveChangesAsync());
        }
        public VbRequestModel MappingData2(VbNonPORequestViewModel viewModel)
        {
            var listDetail = new List <VbRequestDetailModel>();

            var myProperty = viewModel.GetType().GetProperties();

            int value = int.Parse(dbSet.OrderByDescending(p => p.Id)
                                  .Select(r => r.Id)
                                  .First().ToString());

            foreach (var prop in myProperty.Where(x => x.PropertyType == typeof(bool)))
            {
                if ((bool)prop.GetValue(viewModel))
                {
                    var item = new VbRequestDetailModel()
                    {
                        VBId              = value,
                        UnitName          = prop.Name,
                        LastModifiedBy    = viewModel.LastModifiedBy,
                        LastModifiedAgent = viewModel.LastModifiedAgent,
                        DeletedBy         = "",
                        DeletedAgent      = "",
                        CreatedBy         = viewModel.CreatedBy,
                        CreatedAgent      = viewModel.CreatedAgent,
                    };
                    if (prop.Name.ToUpper() == "OTHERS")
                    {
                        item.DetailOthers = viewModel.DetailOthers;
                    }
                    listDetail.Add(item);
                    //EntityExtension.FlagForCreate(item, _identityService.Username, UserAgent);
                    //_dbContext.VbRequestsDetails.Add(item);
                    //_dbContext.SaveChangesAsync();
                }
            }
            var result = new VbRequestModel()
            {
                VbRequestDetail = listDetail,
                Active          = viewModel.Active,
                Id                  = viewModel.Id,
                Date                = (DateTimeOffset)viewModel.Date,
                DateEstimate        = (DateTimeOffset)viewModel.DateEstimate,
                UnitId              = viewModel.Unit.Id,
                UnitCode            = viewModel.Unit.Code,
                UnitName            = viewModel.Unit.Name,
                UnitDivisionId      = viewModel.Division.Id,
                UnitDivisionName    = viewModel.Division.Name,
                VBNo                = viewModel.VBNo,
                CurrencyId          = viewModel.Currency.Id,
                CurrencyCode        = viewModel.Currency.Code,
                CurrencyRate        = viewModel.Currency.Rate,
                CurrencySymbol      = viewModel.Currency.Symbol,
                CurrencyDescription = viewModel.Currency.Description,
                Amount              = viewModel.Amount,
                Usage               = viewModel.Usage,
                UnitLoad            = viewModel.UnitLoad,
                CreatedBy           = viewModel.CreatedBy,
                CreatedAgent        = viewModel.CreatedAgent,
                LastModifiedAgent   = viewModel.LastModifiedAgent,
                LastModifiedBy      = viewModel.LastModifiedBy,
                LastModifiedUtc     = DateTime.Now,
                CreatedUtc          = viewModel.CreatedUtc
            };

            return(result);
        }