Ejemplo n.º 1
0
        protected GarmentShippingCostStructureModel MapToModel(GarmentShippingCostStructureViewModel viewModel)
        {
            viewModel.Comodity = viewModel.Comodity ?? new Comodity();
            GarmentShippingCostStructureModel garmentShippingCostStructureModel = new GarmentShippingCostStructureModel(viewModel.InvoiceNo, viewModel.Date, viewModel.Comodity.Id, viewModel.Comodity.Code, viewModel.Comodity.Name, viewModel.HsCode, viewModel.Destination, viewModel.FabricTypeId, viewModel.FabricType, viewModel.Amount, viewModel.PackingListId);

            return(garmentShippingCostStructureModel);
        }
Ejemplo n.º 2
0
        public virtual async Task <int> Create(GarmentShippingCostStructureViewModel viewModel)
        {
            GarmentShippingCostStructureModel model = MapToModel(viewModel);

            int Created = await _garmentShippingCostStructureRepository.InsertAsync(model);

            return(Created);
        }
Ejemplo n.º 3
0
        public Task <int> InsertAsync(GarmentShippingCostStructureModel model)
        {
            model.FlagForCreate(_identityProvider.Username, UserAgent);

            var packingListModel = _garmentpackingListDbSet.FirstOrDefault(entity => entity.Id == model.PackingListId);

            packingListModel.SetIsCostStructured(true, _identityProvider.Username, UserAgent);

            _dbSet.Add(model);

            return(_dbContext.SaveChangesAsync());
        }
Ejemplo n.º 4
0
        public Task <int> UpdateAsync(int id, GarmentShippingCostStructureModel model)
        {
            var modelToUpdate = _dbSet.FirstOrDefault(s => s.Id == id);

            modelToUpdate.SetComodityId(model.ComodityId, _identityProvider.Username, UserAgent);
            modelToUpdate.SetComodityCode(model.ComodityCode, _identityProvider.Username, UserAgent);
            modelToUpdate.SetComodityName(model.ComodityName, _identityProvider.Username, UserAgent);
            modelToUpdate.SetHsCode(model.HsCode, _identityProvider.Username, UserAgent);
            modelToUpdate.SetDestination(model.Destination, _identityProvider.Username, UserAgent);
            modelToUpdate.SetAmount(model.Amount, _identityProvider.Username, UserAgent);
            modelToUpdate.SetFabricType(model.FabricType, _identityProvider.Username, UserAgent);

            return(_dbContext.SaveChangesAsync());
        }
Ejemplo n.º 5
0
        public async Task ReadPdfById_ViscoseFujiette_Success()
        {
            var model = new GarmentShippingCostStructureModel("invoiceno", DateTimeOffset.Now, 1, "comodityCode", "comodityName", "hsCode", "destination", 1, "VISCOSE FUJIETTE", 10000, 1);

            var repoMock = new Mock <IGarmentShippingCostStructureRepository>();

            repoMock.Setup(s => s.ReadByIdAsync(It.IsAny <int>()))
            .ReturnsAsync(model);

            var service = GetService(GetServiceProvider(repoMock.Object).Object);

            var result = await service.ReadPdfById(1);

            Assert.NotNull(result);
        }
Ejemplo n.º 6
0
        public void Read_Success()
        {
            var model = new GarmentShippingCostStructureModel("invoiceno", DateTimeOffset.Now, 1, "comodityCode", "comodityName", "hsCode", "destination", 1, "fabricType", 10000, 1);

            var repoMock = new Mock <IGarmentShippingCostStructureRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingCostStructureModel>()
            {
                model
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object).Object);

            var result = service.Read(1, 25, "{}", "{}", null);

            Assert.NotEmpty(result.Data);
        }
Ejemplo n.º 7
0
        protected GarmentShippingCostStructureViewModel MapToViewModel(GarmentShippingCostStructureModel model)
        {
            var vm = new GarmentShippingCostStructureViewModel()
            {
                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,

                InvoiceNo     = model.InvoiceNo,
                PackingListId = model.PackingListId,
                Date          = model.Date,
                Comodity      = new Comodity
                {
                    Id   = model.ComodityId,
                    Code = model.ComodityCode,
                    Name = model.ComodityName
                },
                HsCode      = model.HsCode,
                Destination = model.Destination,
                //FabricTypeId = model.FabricTypeId,
                FabricType = model.FabricType,
                Amount     = model.Amount,
                //Items = (model.Items ?? new List<GarmentShippingCostStructureItemModel>()).Select(i => new GarmentShippingCostStructureItemViewModel
                //{
                //    Active = i.Active,
                //    Id = i.Id,
                //    CreatedAgent = i.CreatedAgent,
                //    CreatedBy = i.CreatedBy,
                //    CreatedUtc = i.CreatedUtc,
                //    DeletedAgent = i.DeletedAgent,
                //    DeletedBy = i.DeletedBy,
                //    DeletedUtc = i.DeletedUtc,
                //    IsDeleted = i.IsDeleted,
                //    LastModifiedAgent = i.LastModifiedAgent,
                //    LastModifiedBy = i.LastModifiedBy,
                //    LastModifiedUtc = i.LastModifiedUtc,

                //    SummaryValue = i.SummaryValue,
                //    SummaryPercentage = i.SummaryPercentage,
                //    CostStructureType = i.CostStructureType,

                //    Details = (i.Details ?? new List<GarmentShippingCostStructureDetailModel>()).Select(d => new GarmentShippingCostStructureDetailViewModel
                //    {
                //        Active = d.Active,
                //        Id = d.Id,
                //        CreatedAgent = d.CreatedAgent,
                //        CreatedBy = d.CreatedBy,
                //        CreatedUtc = d.CreatedUtc,
                //        DeletedAgent = d.DeletedAgent,
                //        DeletedBy = d.DeletedBy,
                //        DeletedUtc = d.DeletedUtc,
                //        IsDeleted = d.IsDeleted,
                //        LastModifiedAgent = d.LastModifiedAgent,
                //        LastModifiedBy = d.LastModifiedBy,
                //        LastModifiedUtc = d.LastModifiedUtc,

                //        Description = d.Description,
                //        CountryFrom = d.CountryFrom,
                //        Percentage = d.Percentage,
                //        Value = d.Value
                //    }).ToList(),
                //}).ToList()
            };

            return(vm);
        }
Ejemplo n.º 8
0
        public async Task <int> Update(int id, GarmentShippingCostStructureViewModel viewModel)
        {
            GarmentShippingCostStructureModel garmentShippingCostStructure = MapToModel(viewModel);

            return(await _garmentShippingCostStructureRepository.UpdateAsync(id, garmentShippingCostStructure));
        }