public async Task <FAGTextResponse> AddFAGTextAsync(AddFAGTextRequest request) { FAGText fagText = _fagTextMapper.Map(request); FAGText result = _fagTextRespository.Add(fagText); int modifiedRecords = await _fagTextRespository.UnitOfWork.SaveChangesAsync(); _logger.LogInformation(Events.Add, Messages.NumberOfRecordAffected_modifiedRecords, modifiedRecords); _logger.LogInformation(Events.Add, Messages.ChangesApplied_id, result?.Id); return(_fagTextMapper.Map(result)); }
public async Task <FAGTextResponse> GetFAGTextAsync(Guid id) { if (id == null) { throw new ArgumentNullException(); } FAGText entity = await _fagTextRespository.GetAsync(id); _logger.LogInformation(Events.GetById, Messages.TargetEntityChanged_id, entity?.Id); return(_fagTextMapper.Map(entity)); }
public FAGText Map(AddFAGTextRequest request) { if (request == null) { return(null); } FAGText fagText = new FAGText { Text = request.Text, TextRTF = request.TextRTF, Iso3cc = request.Iso3cc, Iso2cc = request.Iso2cc, }; return(fagText); }
public async Task <FAGTextResponse> EditFAGTextAsync(EditFAGTextRequest request) { FAGText existingRecord = await _fagTextRespository.GetAsync(request.Id); if (existingRecord == null) { throw new ArgumentException($"Entity with {request.Id} is not present"); } FAGText entity = _fagTextMapper.Map(request); FAGText result = _fagTextRespository.Update(entity); int modifiedRecords = await _fagTextRespository.UnitOfWork.SaveChangesAsync(); _logger.LogInformation(Logging.Events.Edit, Messages.NumberOfRecordAffected_modifiedRecords, modifiedRecords); _logger.LogInformation(Logging.Events.Edit, Messages.ChangesApplied_id, result?.Id); return(_fagTextMapper.Map(result)); }
public FAGTextResponse Map(FAGText fagText) { if (fagText == null) { return(null); } ; FAGTextResponse response = new FAGTextResponse { Id = fagText.Id, Text = fagText.Text, TextRTF = fagText.TextRTF, Iso3cc = fagText.Iso3cc, Iso2cc = fagText.Iso2cc }; return(response); }
public async Task <FAGTextResponse> DeleteFAGTextAsync(DeleteFAGTextRequest request) { if (request?.Id == null) { throw new ArgumentNullException(); } FAGText result = await _fagTextRespository.GetAsync(request.Id); if (result == null) { throw new ArgumentException($"Entity with {request.Id} is not present"); } _fagTextRespository.Update(result); int modifiedRecords = await _fagTextRespository.UnitOfWork.SaveChangesAsync(); _logger.LogInformation(Logging.Events.Delete, Messages.NumberOfRecordAffected_modifiedRecords, modifiedRecords); return(_fagTextMapper.Map(result)); }
public async Task <DocumentResponse> EditDocumentAsync(EditDocumentRequest request) { Document existingRecord = await _documentRespository.GetAsync(request.Id); if (existingRecord == null) { throw new ArgumentException($"Entity with {request.Id} is not present"); } if (request.TextStartId != null) { FAGText existingTextStart = await _fagTextRespository.GetAsync((Guid)request.TextStartId); if (existingTextStart == null) { throw new NotFoundException($"TextStart with {request.TextStartId} is not present"); } } if (request.TextHeadId != null) { FAGText existingTextHead = await _fagTextRespository.GetAsync((Guid)request.TextHeadId); if (existingTextHead == null) { throw new NotFoundException($"TextHead with {request.TextHeadId} is not present"); } } if (request.TextPaymentTermsId != null) { FAGText existingTextPaymentTerms = await _fagTextRespository.GetAsync((Guid)request.TextPaymentTermsId); if (existingTextPaymentTerms == null) { throw new NotFoundException($"TextPaymentTerms with {request.TextPaymentTermsId} is not present"); } } if (request.TextDeliveryId != null) { FAGText existingTextDelivery = await _fagTextRespository.GetAsync((Guid)request.TextDeliveryId); if (existingTextDelivery == null) { throw new NotFoundException($"TextDelivery with {request.TextDeliveryId} is not present"); } } if (request.TextEndId != null) { FAGText existingTextEnd = await _fagTextRespository.GetAsync((Guid)request.TextEndId); if (existingTextEnd == null) { throw new NotFoundException($"TextEnd with {request.TextEndId} is not present"); } } if (request.DocumentPersonId != null) { Person existingDocumentPerson = await _personRespository.GetAsync((Guid)request.DocumentPersonId); if (existingDocumentPerson == null) { throw new NotFoundException($"DocumentPerson with {request.DocumentPersonId} is not present"); } } if (request.DocumentCompanyId != null) { Company existingDocumentCompany = await _addressRespository.GetAsync((Guid)request.DocumentCompanyId); if (existingDocumentCompany == null) { throw new NotFoundException($"DocumentCompany with {request.DocumentCompanyId} is not present"); } } if (request.DeliveryPersonId != null) { Person existingDeliveryPerson = await _personRespository.GetAsync((Guid)request.DeliveryPersonId); if (existingDeliveryPerson == null) { throw new NotFoundException($"DeliveryPerson with {request.DeliveryPersonId} is not present"); } } if (request.DeliveryCompanyId != null) { Company existingDeliveryCompany = await _addressRespository.GetAsync((Guid)request.DeliveryCompanyId); if (existingDeliveryCompany == null) { throw new NotFoundException($"DeliveryCompany with {request.DeliveryCompanyId} is not present"); } } if (request.InvoicePersonId != null) { Person existingInvoicePerson = await _personRespository.GetAsync((Guid)request.InvoicePersonId); if (existingInvoicePerson == null) { throw new NotFoundException($"InvoicePerson with {request.InvoicePersonId} is not present"); } } if (request.InvoiceCompanyId != null) { Company existingInvoiceCompany = await _addressRespository.GetAsync((Guid)request.InvoiceCompanyId); if (existingInvoiceCompany == null) { throw new NotFoundException($"InvoiceCompany with {request.InvoiceCompanyId} is not present"); } } Document entity = _documentMapper.Map(request); Document result = _documentRespository.Update(entity); int modifiedRecords = await _documentRespository.UnitOfWork.SaveChangesAsync(); _logger.LogInformation(Logging.Events.Edit, Messages.NumberOfRecordAffected_modifiedRecords, modifiedRecords); _logger.LogInformation(Logging.Events.Edit, Messages.ChangesApplied_id, result?.Id); return(_documentMapper.Map(result)); }
public FAGText Update(FAGText address) { _context.Entry(address).State = EntityState.Modified; return(address); }
public async Task <FAGText> GetAsync(Guid id) { FAGText address = await _context.FAGTexts.AsNoTracking().Where(x => x.Id == id).FirstOrDefaultAsync(); return(address); }
public FAGText Add(FAGText address) { return(_context.FAGTexts.Add(address).Entity); }