public Task <int> InsertAsync(GarmentShippingAmendLetterOfCreditModel model) { model.FlagForCreate(_identityProvider.Username, UserAgent); _dbSet.Add(model); return(_dbContext.SaveChangesAsync()); }
private GarmentAmendLetterOfCreditViewModel MapToViewModel(GarmentShippingAmendLetterOfCreditModel model) { GarmentAmendLetterOfCreditViewModel viewModel = new GarmentAmendLetterOfCreditViewModel { 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, amount = model.Amount, description = model.Description, amendNumber = model.AmendNumber, date = model.Date, documentCreditNo = model.DocumentCreditNo, letterOfCreditId = model.LetterOfCreditId }; return(viewModel); }
public async Task <int> UpdateAsync(int id, GarmentShippingAmendLetterOfCreditModel model) { var modelToUpdate = _dbSet.First(s => s.Id == id); modelToUpdate.SetDate(model.Date, _identityProvider.Username, UserAgent); modelToUpdate.SetDescription(model.Description, _identityProvider.Username, UserAgent); modelToUpdate.SetAmount(model.Amount, _identityProvider.Username, UserAgent); return(await _dbContext.SaveChangesAsync()); }
public async Task ReadById_Success() { var model = new GarmentShippingAmendLetterOfCreditModel("no", 1, 1, DateTimeOffset.Now, "", 2); var repoMock = new Mock <IGarmentAmendLetterOfCreditRepository>(); 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 Read_Success() { var model = new GarmentShippingAmendLetterOfCreditModel("no", 1, 1, DateTimeOffset.Now, "", 2); var repoMock = new Mock <IGarmentAmendLetterOfCreditRepository>(); repoMock.Setup(s => s.ReadAll()) .Returns(new List <GarmentShippingAmendLetterOfCreditModel>() { model }.AsQueryable()); var service = GetService(GetServiceProvider(repoMock.Object).Object); var result = service.Read(1, 25, "{}", "{}", null); Assert.NotEmpty(result.Data); }
public async Task <int> Create(GarmentAmendLetterOfCreditViewModel viewModel) { GarmentShippingAmendLetterOfCreditModel model = new GarmentShippingAmendLetterOfCreditModel(viewModel.documentCreditNo, viewModel.letterOfCreditId, viewModel.amendNumber, viewModel.date, viewModel.description, viewModel.amount); return(await _repository.InsertAsync(model)); }