/// <inheritdoc/> public async Task <Document> CreateDocumentAsync(UpdateDocumentRequest createRequest) { var dbDocument = Mapper.Map <UpdateDocumentRequest, DbDocument>(createRequest); _context.Documents.Add(dbDocument); await _context.SaveChangesAsync(); return(Mapper.Map <Document>(dbDocument)); }
/// <inheritdoc/> public async Task <Document> UpdateDocumentAsync(int departmentId, UpdateDocumentRequest updateRequest) { var dbDocuments = await _context.Documents.Where(d => d.Id == departmentId).ToArrayAsync(); if (dbDocuments.Length == 0) { throw new RequestedResourceNotFoundException(); } var dbDocument = dbDocuments[0]; Mapper.Map(updateRequest, dbDocument); await _context.SaveChangesAsync(); return(Mapper.Map <Document>(dbDocument)); }