public Task <int> InsertAsync(GarmentShippingLocalCoverLetterModel model)
        {
            model.FlagForCreate(_identityProvider.Username, UserAgent);
            _dbSet.Add(model);

            return(_dbContext.SaveChangesAsync());
        }
Beispiel #2
0
        public async Task <int> Create(GarmentLocalCoverLetterViewModel viewModel)
        {
            viewModel.buyer         = viewModel.buyer ?? new Buyer();
            viewModel.shippingStaff = viewModel.shippingStaff ?? new ShippingStaff();
            GarmentShippingLocalCoverLetterModel model = new GarmentShippingLocalCoverLetterModel(viewModel.localSalesNoteId, viewModel.noteNo, GenerateNo(), viewModel.date.GetValueOrDefault(), viewModel.buyer.Id, viewModel.buyer.Code, viewModel.buyer.Name, viewModel.buyer.Address, viewModel.remark, viewModel.bcNo, viewModel.bcdate.GetValueOrDefault(), viewModel.truck, viewModel.plateNumber, viewModel.driver, viewModel.shippingStaff.id, viewModel.shippingStaff.name);

            return(await _repository.InsertAsync(model));
        }
        public void GetReportData_LMS_Success()
        {
            var items = new List <GarmentShippingLocalSalesNoteItemModel>
            {
                new GarmentShippingLocalSalesNoteItemModel(1, 1, "", "", 1, 1, "UOM1", 1, 1, 1, "")
                {
                    LocalSalesNoteId = 1
                },
                new GarmentShippingLocalSalesNoteItemModel(1, 1, "", "", 1, 2, "UOM2", 1, 1, 1, "")
                {
                    LocalSalesNoteId = 1
                },
                new GarmentShippingLocalSalesNoteItemModel(1, 1, "", "", 1, 1, "UOM1", 1, 1, 1, "")
                {
                    LocalSalesNoteId = 1
                },
            };

            var model = new GarmentShippingLocalSalesNoteModel("", 1, "", "", DateTimeOffset.Now, 1, "LMS", "LMS TRANSAKSI", 1, "A999", "", "", "", 1, "", "", true, "", false, false, false, null, null, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", items)
            {
                Id = 1
            };

            var model2 = new GarmentShippingLocalCoverLetterModel(1, "", "", DateTimeOffset.Now, 1, "", "", "", "", "BC123", DateTimeOffset.Now, "", "", "", 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(items.AsQueryable());

            var repoMock2 = new Mock <IGarmentLocalCoverLetterRepository>();

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

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

            var result = service.GetReportData(DateTime.MinValue, DateTime.Now, 0);

            Assert.NotEmpty(result.ToList());
        }
        public async Task ReadByLocalSalesNoteId_Success_null()
        {
            var model = new GarmentShippingLocalCoverLetterModel(1, "", "", DateTimeOffset.Now, 1, "", "", "", "", "BC123", DateTimeOffset.Now, "", "", "", 1, "");

            var repoMock = new Mock <IGarmentLocalCoverLetterRepository>();
            //repoMock.Setup(s => s.ReadByLocalSalesNoteIdAsync(It.IsAny<int>()))
            //    .ReturnsAsync(model);

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

            var result = await service.ReadByLocalSalesNoteId(0);

            Assert.Null(result);
        }
        public async Task <int> UpdateAsync(int id, GarmentShippingLocalCoverLetterModel model)
        {
            var modelToUpdate = _dbSet.First(s => s.Id == id);

            modelToUpdate.SetDate(model.Date, _identityProvider.Username, UserAgent);
            modelToUpdate.SetBCNo(model.BCNo, _identityProvider.Username, UserAgent);
            modelToUpdate.SetBCDate(model.BCDate, _identityProvider.Username, UserAgent);
            modelToUpdate.SetRemark(model.Remark, _identityProvider.Username, UserAgent);
            modelToUpdate.SetTruck(model.Truck, _identityProvider.Username, UserAgent);
            modelToUpdate.SetPlateNumber(model.PlateNumber, _identityProvider.Username, UserAgent);
            modelToUpdate.SetDriver(model.Driver, _identityProvider.Username, UserAgent);
            modelToUpdate.SetShippingStaffId(model.ShippingStaffId, _identityProvider.Username, UserAgent);
            modelToUpdate.SetShippingStaffName(model.ShippingStaffName, _identityProvider.Username, UserAgent);

            return(await _dbContext.SaveChangesAsync());
        }
        public void Read_Success()
        {
            var model = new GarmentShippingLocalCoverLetterModel(1, "", "", DateTimeOffset.Now, 1, "", "", "", "", "", DateTimeOffset.Now, "", "", "", 1, "");

            var repoMock = new Mock <IGarmentLocalCoverLetterRepository>();

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

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

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

            Assert.NotEmpty(result.Data);
        }
Beispiel #7
0
        private GarmentLocalCoverLetterViewModel MapToViewModel(GarmentShippingLocalCoverLetterModel model)
        {
            GarmentLocalCoverLetterViewModel viewModel = new GarmentLocalCoverLetterViewModel
            {
                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,

                localSalesNoteId   = model.LocalSalesNoteId,
                localCoverLetterNo = model.LocalCoverLetterNo,
                noteNo             = model.NoteNo,
                date  = model.Date,
                buyer = new Buyer
                {
                    Id      = model.BuyerId,
                    Code    = model.BuyerCode,
                    Name    = model.BuyerName,
                    Address = model.BuyerAdddress
                },
                remark        = model.Remark,
                bcNo          = model.BCNo,
                bcdate        = model.BCDate,
                truck         = model.Truck,
                plateNumber   = model.PlateNumber,
                driver        = model.Driver,
                shippingStaff = new ShippingStaff
                {
                    id   = model.ShippingStaffId,
                    name = model.ShippingStaffName
                }
            };

            return(viewModel);
        }