public Task <int> InsertAsync(GarmentShippingLocalSalesNoteItemModel model)
        {
            model.FlagForCreate(_identityProvider.Username, USER_AGENT);

            _dbSet.Add(model);

            return(_dbContext.SaveChangesAsync());
        }
Ejemplo n.º 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);
        }
        public Task <int> UpdateAsync(int id, GarmentShippingLocalSalesNoteItemModel model)
        {
            var modelToUpdate = _dbSet
                                .FirstOrDefault(s => s.Id == id);

            modelToUpdate.SetProductId(model.ProductId, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetProductCode(model.ProductCode, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetProductName(model.ProductName, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetQuantity(model.Quantity, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetUomId(model.UomId, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetUomUnit(model.UomUnit, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetPrice(model.Price, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetPackageQuantity(model.PackageQuantity, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetPackageUomId(model.PackageUomId, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetPackageUomUnit(model.PackageUomUnit, _identityProvider.Username, USER_AGENT);

            return(_dbContext.SaveChangesAsync());
        }
        public async Task ReadById_Success()
        {
            var items = new List <GarmentShippingLocalSalesNoteItemModel>()
            {
                new GarmentShippingLocalSalesNoteItemModel(1, 1, "", "", 1, 1, "", 1, 1, 1, "")
            };
            var model    = new GarmentShippingLocalSalesNoteModel("", 1, "", "", DateTimeOffset.Now, 1, "", "", 1, "", "", "", "", 1, "", "", true, "", false, false, false, null, null, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", items);
            var item     = new GarmentShippingLocalSalesNoteItemModel();
            var repoMock = new Mock <IGarmentShippingLocalSalesNoteRepository>();

            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);
        }
        public void ReadForFinance_Success()
        {
            var item  = new GarmentShippingLocalSalesNoteItemModel(1, 1, "code", "name", 1, 1, "uom", 1, 1, 1, "uom");
            var items = new List <GarmentShippingLocalSalesNoteItemModel>();

            items.Add(item);
            var model = new GarmentShippingLocalSalesNoteModel("", 1, "", "", DateTimeOffset.Now, 1, "", "", 1, "", "", "", "", 1, "", "", true, "", false, false, false, null, null, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", items);

            var repoMock = new Mock <IGarmentShippingLocalSalesNoteRepository>();

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

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

            var result = service.ReadSalesNoteForFinance("now", model.Date.Month, model.Date.Year, model.BuyerCode);

            Assert.NotEmpty(result.ToList());

            int month = 0;
            int year  = 0;

            if (model.Date.Month == 12)
            {
                month = 1;
                year  = model.Date.Year + 1;
            }
            else
            {
                month = model.Date.Month + 1;
                year  = model.Date.Year;
            }

            var result2 = service.ReadSalesNoteForFinance("", month, year, null);

            //var result2 = service.ReadSalesNoteForFinance("", model.Date.Month, model.Date.Year, null);

            Assert.NotEmpty(result2.ToList());
        }
Ejemplo n.º 6
0
        public void GenerateExcel_Success()
        {
            var item = new GarmentShippingLocalSalesNoteItemModel(1, 1, "", "", 1, 1, "", 1, 1, 1, "")
            {
                LocalSalesNoteId = 1
            };
            var items = new List <GarmentShippingLocalSalesNoteItemModel>()
            {
                item
            };
            var model = new GarmentShippingLocalSalesNoteModel("", 1, "", "", DateTimeOffset.Now, 1, "LJS", "", 1, "", "", "", "", 1, "", "", true, "", false, false, false, null, null, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", items)
            {
                Id = 1
            };


            var repoMock = new Mock <IGarmentShippingLocalSalesNoteRepository>();

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

            var repoMock1 = new Mock <IGarmentShippingLocalSalesNoteItemRepository>();

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

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


            var result = service.GenerateExcel(model.Date.Month, model.Date.Year, 7);

            Assert.NotNull(result);
        }
Ejemplo n.º 7
0
 public GarmentShippingLocalPriceCorrectionNoteItemModel(int salesNoteItemId, GarmentShippingLocalSalesNoteItemModel salesNoteItem, double priceCorrection)
 {
     SalesNoteItemId = salesNoteItemId;
     SalesNoteItem   = salesNoteItem;
     PriceCorrection = priceCorrection;
 }
 public GarmentShippingLocalReturnNoteItemModel(int salesNoteItemId, GarmentShippingLocalSalesNoteItemModel salesNoteItem, double returnQuantity)
 {
     SalesNoteItemId = salesNoteItemId;
     SalesNoteItem   = salesNoteItem;
     ReturnQuantity  = returnQuantity;
 }