public Task <int> InsertAsync(GarmentShippingLocalReturnNoteModel 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 <GarmentShippingLocalReturnNoteItemModel>() { new GarmentShippingLocalReturnNoteItemModel(1, new GarmentShippingLocalSalesNoteItemModel(1, 1, "", "", 1, 1, "", 1, 1, 1, ""), 1) }; var model = new GarmentShippingLocalReturnNoteModel("", 1, DateTimeOffset.Now, "", new GarmentShippingLocalSalesNoteModel("", 1, "", "", DateTimeOffset.Now, 1, "", "", 1, "", "", "", "", 1, "", "", true, "", true, null), items); var repoMock = new Mock <IGarmentShippingLocalReturnNoteRepository>(); 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 GarmentShippingLocalReturnNoteModel("", 1, DateTimeOffset.Now, "", new GarmentShippingLocalSalesNoteModel("", 1, "", "", DateTimeOffset.Now, 1, "", "", 1, "", "", "", "", 1, "", "", true, "", true, null), new List <GarmentShippingLocalReturnNoteItemModel>()); var repoMock = new Mock <IGarmentShippingLocalReturnNoteRepository>(); repoMock.Setup(s => s.ReadAll()) .Returns(new List <GarmentShippingLocalReturnNoteModel>() { model }.AsQueryable()); var service = GetService(GetServiceProvider(repoMock.Object).Object); var result = service.Read(1, 25, "{}", "{}", null); Assert.NotEmpty(result.Data); }
private GarmentShippingLocalReturnNoteViewModel MapToViewModel(GarmentShippingLocalReturnNoteModel model) { GarmentShippingLocalReturnNoteViewModel viewModel = new GarmentShippingLocalReturnNoteViewModel { 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, returnNoteNo = model.ReturnNoteNo, returnDate = model.ReturnDate, description = model.Description, 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, }, items = (model.Items ?? new List <GarmentShippingLocalReturnNoteItemModel>()).Select(i => new GarmentShippingLocalReturnNoteItemViewModel { 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, returnQuantity = i.ReturnQuantity, 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); }
public Task <int> UpdateAsync(int id, GarmentShippingLocalReturnNoteModel model) { return(Task.FromResult(1)); }