Example #1
0
        public Task <int> InsertAsync(GarmentShippingLocalPriceCorrectionNoteModel model)
        {
            model.FlagForCreate(_identityProvider.Username, UserAgent);

            foreach (var item in model.Items)
            {
                item.FlagForCreate(_identityProvider.Username, UserAgent);
            }

            _dbSet.Add(model);

            return(_dbContext.SaveChangesAsync());
        }
Example #2
0
        public async Task ReadPdfById_Success()
        {
            var salesNoteItem  = new GarmentShippingLocalSalesNoteItemModel(1, 1, "", "", 1, 1, "", 1, 1, 1, "");
            var salesNoteItems = new List <GarmentShippingLocalSalesNoteItemModel>()
            {
                salesNoteItem
            };
            var salesNoteModel = new GarmentShippingLocalSalesNoteModel("", 1, "", "", DateTimeOffset.Now, 1, "", "", 1, "", "", "", "", 1, "", "", true, "", false, salesNoteItems);

            var items = new HashSet <GarmentShippingLocalPriceCorrectionNoteItemModel> {
                new GarmentShippingLocalPriceCorrectionNoteItemModel(1, salesNoteItem, 1)
            };
            var model = new GarmentShippingLocalPriceCorrectionNoteModel("", DateTimeOffset.Now, 1, salesNoteModel, "", items);

            var repoMock = new Mock <IGarmentShippingLocalPriceCorrectionNoteRepository>();

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

            var httpMock = new Mock <IHttpClientService>();

            httpMock.Setup(s => s.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(new { data = new Buyer() }))
            });

            var spMock = GetServiceProvider(repoMock.Object);

            spMock.Setup(s => s.GetService(typeof(IHttpClientService)))
            .Returns(httpMock.Object);
            spMock.Setup(s => s.GetService(typeof(IIdentityProvider)))
            .Returns(new IdentityProvider
            {
                TimezoneOffset = 7,
                Token          = "INITOKEN",
                Username       = "******"
            });

            var service = GetService(spMock.Object);

            var result = await service.ReadPdfById(1);

            Assert.NotNull(result);
        }
Example #3
0
        public void Read_Success()
        {
            var model = new GarmentShippingLocalPriceCorrectionNoteModel("", DateTimeOffset.Now, 1, new GarmentShippingLocalSalesNoteModel("", 1, "", "", DateTimeOffset.Now, 1, "", "", 1, "", "", "", "", 1, "", "", true, "", true, null), "", new List <GarmentShippingLocalPriceCorrectionNoteItemModel>());

            var repoMock = new Mock <IGarmentShippingLocalPriceCorrectionNoteRepository>();

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

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

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

            Assert.NotEmpty(result.Data);
        }
Example #4
0
        public async Task ReadById_Success()
        {
            var items = new List <GarmentShippingLocalPriceCorrectionNoteItemModel>()
            {
                new GarmentShippingLocalPriceCorrectionNoteItemModel(1, new GarmentShippingLocalSalesNoteItemModel(1, 1, "", "", 1, 1, "", 1, 1, 1, ""), 1)
            };
            var model = new GarmentShippingLocalPriceCorrectionNoteModel("", DateTimeOffset.Now, 1, new GarmentShippingLocalSalesNoteModel("", 1, "", "", DateTimeOffset.Now, 1, "", "", 1, "", "", "", "", 1, "", "", true, "", true, null), null, items);

            var repoMock = new Mock <IGarmentShippingLocalPriceCorrectionNoteRepository>();

            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);
        }
Example #5
0
 public Task <int> UpdateAsync(int id, GarmentShippingLocalPriceCorrectionNoteModel model)
 {
     return(Task.FromResult(1));
 }
Example #6
0
        private GarmentShippingLocalPriceCorrectionNoteViewModel MapToViewModel(GarmentShippingLocalPriceCorrectionNoteModel model)
        {
            GarmentShippingLocalPriceCorrectionNoteViewModel viewModel = new GarmentShippingLocalPriceCorrectionNoteViewModel
            {
                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,

                correctionNoteNo = model.CorrectionNoteNo,
                correctionDate   = model.CorrectionDate,
                salesNote        = new GarmentShippingLocalSalesNoteViewModel
                {
                    Active            = model.SalesNote.Active,
                    Id                = model.SalesNote.Id,
                    CreatedAgent      = model.SalesNote.CreatedAgent,
                    CreatedBy         = model.SalesNote.CreatedBy,
                    CreatedUtc        = model.SalesNote.CreatedUtc,
                    DeletedAgent      = model.SalesNote.DeletedAgent,
                    DeletedBy         = model.SalesNote.DeletedBy,
                    DeletedUtc        = model.SalesNote.DeletedUtc,
                    IsDeleted         = model.SalesNote.IsDeleted,
                    LastModifiedAgent = model.SalesNote.LastModifiedAgent,
                    LastModifiedBy    = model.SalesNote.LastModifiedBy,
                    LastModifiedUtc   = model.SalesNote.LastModifiedUtc,

                    noteNo          = model.SalesNote.NoteNo,
                    date            = model.SalesNote.Date,
                    transactionType = new TransactionType
                    {
                        id   = model.SalesNote.TransactionTypeId,
                        code = model.SalesNote.TransactionTypeCode,
                        name = model.SalesNote.TransactionTypeName
                    },
                    buyer = new Buyer
                    {
                        Id   = model.SalesNote.BuyerId,
                        Code = model.SalesNote.BuyerCode,
                        Name = model.SalesNote.BuyerName,
                        npwp = model.SalesNote.BuyerNPWP
                    },
                    tempo         = model.SalesNote.Tempo,
                    dispositionNo = model.SalesNote.DispositionNo,
                    useVat        = model.SalesNote.UseVat,
                    remark        = model.SalesNote.Remark,
                    isUsed        = model.SalesNote.IsUsed,
                },
                remark = model.Remark,

                items = (model.Items ?? new List <GarmentShippingLocalPriceCorrectionNoteItemModel>()).Select(i => new GarmentShippingLocalPriceCorrectionNoteItemViewModel
                {
                    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,

                    isChecked       = true,
                    priceCorrection = i.PriceCorrection,
                    salesNoteItem   = new GarmentShippingLocalSalesNoteItemViewModel
                    {
                        Active            = i.SalesNoteItem.Active,
                        Id                = i.SalesNoteItem.Id,
                        CreatedAgent      = i.SalesNoteItem.CreatedAgent,
                        CreatedBy         = i.SalesNoteItem.CreatedBy,
                        CreatedUtc        = i.SalesNoteItem.CreatedUtc,
                        DeletedAgent      = i.SalesNoteItem.DeletedAgent,
                        DeletedBy         = i.SalesNoteItem.DeletedBy,
                        DeletedUtc        = i.SalesNoteItem.DeletedUtc,
                        IsDeleted         = i.SalesNoteItem.IsDeleted,
                        LastModifiedAgent = i.SalesNoteItem.LastModifiedAgent,
                        LastModifiedBy    = i.SalesNoteItem.LastModifiedBy,
                        LastModifiedUtc   = i.SalesNoteItem.LastModifiedUtc,

                        product = new ProductViewModel
                        {
                            id   = i.SalesNoteItem.ProductId,
                            code = i.SalesNoteItem.ProductCode,
                            name = i.SalesNoteItem.ProductName
                        },
                        quantity = i.SalesNoteItem.Quantity,
                        uom      = new UnitOfMeasurement
                        {
                            Id   = i.SalesNoteItem.UomId,
                            Unit = i.SalesNoteItem.UomUnit
                        },
                        price = i.SalesNoteItem.Price
                    }
                }).ToList()
            };

            return(viewModel);
        }