Exemple #1
0
        public Task <int> InsertAsync(GarmentShippingLetterOfCreditModel model)
        {
            model.FlagForCreate(_identityProvider.Username, UserAgent);
            _dbSet.Add(model);

            return(_dbContext.SaveChangesAsync());
        }
        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));
        }
Exemple #3
0
        public async Task ReadById_Success()
        {
            var model = new GarmentShippingLetterOfCreditModel("no", DateTimeOffset.Now, "", 1, "", "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", 1, 1, "", 2);

            var repoMock = new Mock <IGarmentLetterOfCreditRepository>();

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

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

            var result = await service.ReadById(1);

            Assert.NotNull(result);
        }
Exemple #4
0
        public void GenerateExcel_Success()
        {
            var model = new GarmentShippingLetterOfCreditModel("001", DateTimeOffset.Now, "", 1, "", "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", 1, 1, "", 2)
            {
                Id = 1
            };

            var model1 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "LC", "001", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "")
            {
                Id = 1
            };

            var model2 = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                         "", DateTimeOffset.Now, "", null, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentLetterOfCreditRepository>();

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

            var repoMock2 = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model2
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentPackingListRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model1
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object, repoMock2.Object, repoMock1.Object).Object);

            var result = service.GenerateExcel(model.ApplicantCode, null, DateTime.MinValue, DateTime.MaxValue, 7);

            Assert.NotNull(result);
        }
Exemple #5
0
        public void Read_Success()
        {
            var model = new GarmentShippingLetterOfCreditModel("no", DateTimeOffset.Now, "", 1, "", "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", 1, 1, "", 2);

            var repoMock = new Mock <IGarmentLetterOfCreditRepository>();

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

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

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

            Assert.NotEmpty(result.Data);
        }
        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);
        }
Exemple #7
0
        public async Task <int> UpdateAsync(int id, GarmentShippingLetterOfCreditModel model)
        {
            var modelToUpdate = _dbSet.First(s => s.Id == id);

            modelToUpdate.SetDate(model.Date, _identityProvider.Username, UserAgent);
            modelToUpdate.SetApplicantCode(model.ApplicantCode, _identityProvider.Username, UserAgent);
            modelToUpdate.SetApplicantId(model.ApplicantId, _identityProvider.Username, UserAgent);
            modelToUpdate.SetApplicantName(model.ApplicantName, _identityProvider.Username, UserAgent);
            modelToUpdate.SetDocumentCreditNo(model.DocumentCreditNo, _identityProvider.Username, UserAgent);
            modelToUpdate.SetExpireDate(model.ExpireDate, _identityProvider.Username, UserAgent);
            modelToUpdate.SetExpirePlace(model.ExpirePlace, _identityProvider.Username, UserAgent);
            modelToUpdate.SetIssuedBank(model.IssuedBank, _identityProvider.Username, UserAgent);
            modelToUpdate.SetLatestShipment(model.LatestShipment, _identityProvider.Username, UserAgent);
            modelToUpdate.SetLCCondition(model.LCCondition, _identityProvider.Username, UserAgent);
            modelToUpdate.SetQuantity(model.Quantity, _identityProvider.Username, UserAgent);
            modelToUpdate.SetTotalAmount(model.TotalAmount, _identityProvider.Username, UserAgent);
            modelToUpdate.SetUomId(model.UomId, _identityProvider.Username, UserAgent);
            modelToUpdate.SetUomUnit(model.UomUnit, _identityProvider.Username, UserAgent);

            return(await _dbContext.SaveChangesAsync());
        }