Пример #1
0
        private GarmentShippingLocalPriceCuttingNoteViewModel MapToViewModel(GarmentShippingLocalPriceCuttingNoteModel model)
        {
            GarmentShippingLocalPriceCuttingNoteViewModel viewModel = new GarmentShippingLocalPriceCuttingNoteViewModel
            {
                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,

                cuttingPriceNoteNo = model.CuttingPriceNoteNo,
                date  = model.Date,
                buyer = new Buyer
                {
                    Id   = model.BuyerId,
                    Code = model.BuyerCode,
                    Name = model.BuyerName,
                },
                useVat = model.UseVat,
                remark = model.Remark,
                items  = (model.Items ?? new List <GarmentShippingLocalPriceCuttingNoteItemModel>()).Select(i => new GarmentShippingLocalPriceCuttingNoteItemViewModel
                {
                    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,

                    salesNoteId   = i.SalesNoteId,
                    salesNoteNo   = i.SalesNoteNo,
                    salesAmount   = i.SalesAmount,
                    cuttingAmount = i.CuttingAmount,
                    includeVat    = i.IncludeVat
                }).ToList()
            };

            return(viewModel);
        }
        public Task <int> InsertAsync(GarmentShippingLocalPriceCuttingNoteModel model)
        {
            model.FlagForCreate(_identityProvider.Username, UserAgent);

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

            _dbSet.Add(model);

            return(_dbContext.SaveChangesAsync());
        }
        public void Should_Success_Get_BuyerViewModel()
        {
            var items = new List <GarmentShippingLocalPriceCuttingNoteItemModel>()
            {
                new GarmentShippingLocalPriceCuttingNoteItemModel(1, "", 1, 1, true)
            };
            var model = new GarmentShippingLocalPriceCuttingNoteModel("", DateTimeOffset.Now, 1, "", "", true, "", items);

            var repoMock = new Mock <IGarmentShippingLocalPriceCuttingNoteRepository>();

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

            var service = GetService(GetServiceProvider(repoMock.Object).Object);
            var result  = service.GetBuyer(It.IsAny <int>());

            Assert.NotNull(result);
        }
        public void Read_Success()
        {
            var model = new GarmentShippingLocalPriceCuttingNoteModel("", DateTimeOffset.Now, 1, "", "", true, "", new List <GarmentShippingLocalPriceCuttingNoteItemModel>());

            var repoMock = new Mock <IGarmentShippingLocalPriceCuttingNoteRepository>();

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

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

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

            Assert.NotEmpty(result.Data);
        }
 public Task <int> UpdateAsync(int id, GarmentShippingLocalPriceCuttingNoteModel model)
 {
     return(Task.FromResult(1));
 }